Skip to content

Commit

Permalink
Merge e80e933 into f895555
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh authored Dec 18, 2024
2 parents f895555 + e80e933 commit a466199
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-rules-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---

Combobox: Only open dropdown-list onClick, not onFocus.
1 change: 0 additions & 1 deletion @navikt/core/react/src/form/combobox/ComboboxWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const ComboboxWrapper = ({
!wrapperRef.current?.contains(event.relatedTarget) &&
toggleOpenButtonRef?.current !== event.target
) {
toggleIsListOpen(true);
setHasFocusWithin(true);
}
}
Expand Down
12 changes: 10 additions & 2 deletions @navikt/core/react/src/form/combobox/Input/InputController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const InputController = forwardRef<
toggleListButton = true,
inputClassName,
shouldShowSelectedOptions = true,

...rest
} = props;

Expand All @@ -45,7 +46,7 @@ export const InputController = forwardRef<
readOnly,
} = useInputContext();

const { activeDecendantId } = useFilteredOptionsContext();
const { activeDecendantId, toggleIsListOpen } = useFilteredOptionsContext();
const { selectedOptions } = useSelectedOptionsContext();

const mergedInputRef = useMergeRefs(inputRef, ref);
Expand All @@ -57,7 +58,14 @@ export const InputController = forwardRef<
"navds-combobox__wrapper-inner--virtually-unfocused":
activeDecendantId !== undefined,
})}
onClick={focusInput}
onClick={() => {
if (inputProps.disabled || readOnly) {
return;
}

toggleIsListOpen(true);
focusInput();
}}
>
{!shouldShowSelectedOptions ? (
<Input
Expand Down

0 comments on commit a466199

Please sign in to comment.