Skip to content

Commit

Permalink
Merge pull request #1249 from danskernesdigitalebibliotek/fix/DDFLSBP…
Browse files Browse the repository at this point in the history
…-601-avanceret-sogning-dropdowns-benytter-forkerte-sogekoder

Add unique ids for checkboxes [DDFLSBP-601]
  • Loading branch information
clausbruun authored Jun 5, 2024
2 parents 91f5f90 + 421b180 commit b604e9f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/apps/advanced-search/advanced-search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ describe("Search Result", () => {
"contain",
"'Harry' AND 'Prince' AND term.generalmaterialtype='bøger'"
);
cy.getBySel("advanced-search-accessibility")
.first()
.click()
.find("li")
.eq(2)
.should("contain", "Online")
.click();
cy.getBySel("advanced-search-accessibility").first().click();
cy.getBySel("preview-section", true).should(
"contain",
"'Harry' AND 'Prince' AND term.generalmaterialtype='bøger' AND term.accesstype='online'"
);
});

it("Should reset the form upon reset button click", () => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/multiselect/Multiselect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useRef, useState } from "react";
import React, { FC, useId, useRef, useState } from "react";
import IconExpand from "@danskernesdigitalebibliotek/dpl-design-system/build/icons/collection/ExpandMore.svg";
import { useMultipleSelection } from "downshift";
import clsx from "clsx";
Expand Down Expand Up @@ -30,6 +30,7 @@ const Multiselect: FC<MultiselectProps> = ({
defaultValue = [],
updateExternalState
}) => {
const id = useId();
const t = useText();
const ref = useRef(null);
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
Expand Down Expand Up @@ -189,7 +190,7 @@ const Multiselect: FC<MultiselectProps> = ({
</span>
<div className="checkbox multiselect__checkbox">
<CheckBox
id={index.toString()}
id={`${id}-${index.toString()}`}
selected={
!!selectedItems.find(
(selected) => selected.value === item.value
Expand Down

0 comments on commit b604e9f

Please sign in to comment.