-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Combobox: trailing spaces are no longer accepted autocomplete-letters #3105
Conversation
🦋 Changeset detectedLatest commit: a388497 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Storybook demo9c17425c1 | 88 komponenter | 139 stories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀 Nice to have a small comment for future us when we inevitably end up doing some refactors 📝
return list.find((listItem) => | ||
normalizeText(listItem.label).startsWith(normalizedText), | ||
normalizeText(listItem.label).startsWith(text.toLocaleLowerCase()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalizeText(listItem.label).startsWith(text.toLocaleLowerCase()), | |
// We deliberately avoid using `normalizeText()` to avoid trimming input | |
normalizeText(listItem.label).startsWith(text.toLocaleLowerCase()), |
Description
Found this bug a while ago. The bug: After triggering autocomplete, adding a trailing space will continue the suggestion. For example, writing "ap " (with two trailing spaces) will be interpreted as having written "appl", given that the first autocomplete suggestion is "apple". Spaces almost function as a wildcard. A letter after the space(s) stops the behaviour.
This fix: trailing spaces no longer work as wildcards in autocomplete. They still work as spaces for multiple words.
Discussion:
With this fix, writing spaces still don't filter out items in the dropdown (like writing a letter will). So adding a space after a word won't remove all results that don't include that space. This might be convenient in some cases, but it also allows for confusing edge cases like this:
Here, the third (instead of the first) option in the dropdown is the autocomplete suggestion. Is the fact that the autocomplete result is not always on top more confusing than it is convenient? If so, I will make space like letters