Skip to content

Commit

Permalink
Merge a388497 into 27c43ef
Browse files Browse the repository at this point in the history
  • Loading branch information
larseirikhansen authored Aug 15, 2024
2 parents 27c43ef + a388497 commit 9c17425
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-jeans-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---

:bug: Combobox: trailing spaces no longer work like wildcards for autocomplete suggestions
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ const getMatchingValuesFromList = (value: string, list: ComboboxOption[]) =>
list.filter((listItem) => isPartOfText(value, listItem.label));

const getFirstValueStartingWith = (text: string, list: ComboboxOption[]) => {
const normalizedText = normalizeText(text);
return list.find((listItem) =>
normalizeText(listItem.label).startsWith(normalizedText),
normalizeText(listItem.label).startsWith(text.toLocaleLowerCase()),
);
};

Expand Down
4 changes: 3 additions & 1 deletion @navikt/core/react/src/form/combobox/combobox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const options = [
"grape",
"kiwi",
"mango",
"mangosteen",
"mango pie",
"passion fruit",
"pineapple",
"strawberry",
"watermelon",
"grape fruit",
"grapefruit",
];

export const Default: StoryFunction = (props) => (
Expand Down

0 comments on commit 9c17425

Please sign in to comment.