Skip to content

Commit

Permalink
Merge e3f1b0c into aca5143
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianNymark authored Aug 29, 2024
2 parents aca5143 + e3f1b0c commit 8cd4ca0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-beans-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---

Combobox :children_crossing: single select now hides selected value when typing, onBlur clears input
1 change: 1 addition & 0 deletions @navikt/core/css/form/combobox.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
border: none;
padding: 0;
margin: 0;
margin-left: var(--a-spacing-1);
min-width: 10ch;
width: 100%;
height: var(--__ac-combobox-input-height);
Expand Down
3 changes: 2 additions & 1 deletion @navikt/core/react/src/form/combobox/ComboboxWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ComboboxWrapper = ({
inputSize,
toggleIsListOpen,
}: ComboboxWrapperProps) => {
const { toggleOpenButtonRef } = useInputContext();
const { toggleOpenButtonRef, clearInput } = useInputContext();

const wrapperRef = useRef<HTMLDivElement | null>(null);
const [hasFocusWithin, setHasFocusWithin] = useState(false);
Expand All @@ -40,6 +40,7 @@ const ComboboxWrapper = ({
if (!wrapperRef.current?.contains(e.relatedTarget)) {
toggleIsListOpen(false);
setHasFocusWithin(false);
clearInput(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ const SelectedOptions: React.FC<SelectedOptionsProps> = ({
size,
children,
}) => {
const { value } = useInputContext();
const { isMultiSelect } = useSelectedOptionsContext();
return (
<Chips className="navds-combobox__selected-options" size={size}>
{selectedOptions.length
{value.length === 0 || (isMultiSelect && selectedOptions.length)
? selectedOptions.map((option, i) => (
<Option key={option.label + i} option={option} />
))
Expand Down

0 comments on commit 8cd4ca0

Please sign in to comment.