You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: Adjust spacings in token mode autosuggest - #5207
This PR addresses this by removing duplication. Since #5126, the input always render a wrapper div around the native input; we can take advantage of this and create a new internal slot in the internal input component where we pass the inline tokens instead of rendering them in autosuggest-input. This way, the internal input's styles are reused naturally.
How has this been tested?
Existing visual regression tests fail as expected.
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
Changes include appropriate documentation updates.
Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
Changes do not include unsupported browser features, see CONTRIBUTING.md.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The observer discards zero-width measurements, causing tokens to collapse while the field is hidden and preventing recalculation when it is restored at the same width.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Active issues leave a measurement-only button exposed to screen readers in empty token mode and allow stale focus-suppression state to block suggestions and onFocus when the input is refocused.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Stale focus suppression blocks suggestions after returning from token
Nesting tokens inside the dropdown trigger changes its focus boundary: InternalDropdown skips onFocus for token/input transitions, but entering a token still sets preventOpenOnFocusRef. Focus the input, move to a token, return to the input, then leave and refocus the input: the stale flag suppresses both suggestions and onFocus on re-entry. Please update the focus-suppression bookkeeping for the new hierarchy and cover this sequence with a regression test.
When mounted with tokens={[]}, InlineTokens is not rendered, so tokensRef.current is null and this returns before making the measurement container inert. That container still contains the +0 measurement button, whose styles-reset overrides the ancestor's visibility: hidden; clipping it does not remove it from the accessibility tree. Set inert before this readiness guard so screen readers do not encounter a measurement-only button in empty token mode.
The reason will be displayed to describe this comment to others. Learn more.
The warning will now be issued twice in the tests because widths are always 0 in jsdom environments (see this comment for more context), so the behavior here differs from real user experience and this assertion is not very valuable. warnOnce would deduplicate the warning anyway, so real users get only one warning in any case.
The reason will be displayed to describe this comment to others. Learn more.
When measuring the width for the purpose of setting the layout for inline tokens, keeping the width even if they are 0 is more robust (for the edge case that the tokens change while the component is hidden). I researched why the > 0 condition exists and I think it was just to satisfy unit tests, where one more render than expected was triggered because dimensions are 0 in the jsdom environment.
In a real environment, the trigger being 0 can only happen if it is hidden. This should not happen while the dropdown is being rendered, and even if it did, the dropdown width would collapse to its own width, not to 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Internal spacings in autosuggest differ a bit depending on whether token mode is used or not:
No token mode (live example)

Token mode (wider spacings, see live example)

This PR addresses this by removing duplication. Since #5126, the input always render a wrapper div around the native input; we can take advantage of this and create a new internal slot in the internal input component where we pass the inline tokens instead of rendering them in autosuggest-input. This way, the internal input's styles are reused naturally.
How has this been tested?
Existing visual regression tests fail as expected.
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.