Skip to content

Commit

Permalink
fix(InputSelect): ensure consistent options when titles are repeated
Browse files Browse the repository at this point in the history
  • Loading branch information
domihustinova committed Aug 16, 2024
1 parent 08b005e commit 6eb0d75
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/orbit-components/src/InputSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const InputSelect = React.forwardRef<HTMLInputElement, Props>(
if (results.groups.length === 0) {
return results.all.map((option, idx) => {
const { title, description, prefix, value: optValue } = option;
const optionId = randomId(title);
const optionId = randomId(`${title}_${optValue}`);
const isSelected = optValue === selectedOption?.value;
const optionRef = React.createRef() as React.RefObject<HTMLDivElement>;
refs[idx] = optionRef;
Expand Down Expand Up @@ -317,7 +317,7 @@ const InputSelect = React.forwardRef<HTMLInputElement, Props>(
refs[optionIdx] = optionRef;

const { title, description, prefix, value: optValue } = option;
const optionId = randomId(title);
const optionId = randomId(`${title}_${optValue}`);
const isSelected = optValue === selectedOption?.value;

return (
Expand Down Expand Up @@ -359,7 +359,7 @@ const InputSelect = React.forwardRef<HTMLInputElement, Props>(
const optionIdx = idx;
refs[optionIdx] = optionRef;

const optionId = randomId(`all_${title}`);
const optionId = randomId(`all_${title}_${optValue}`);
const isSelected = optValue === selectedOption?.value;

return (
Expand Down

0 comments on commit 6eb0d75

Please sign in to comment.