Repository navigation
Autocomplete: Throw in development when Input is inside Popup - #86674
Conversation
Autocomplete.Popup is the suggestion list for an input outside it. A search input inside a kept-open popup inserts focus guards before the content and traps focus. For a picker that opens from a button, render an inline Autocomplete inside a Popover instead.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +31 B (0%) Total Size: 8.65 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Undo restores the post selection when another synced entity is loaded in
|
Reset the popup context in Root, so the check applies only to the input of the autocomplete that owns the popup. Group the test with the other composition checks and assert the full message.
ciampo
left a comment
There was a problem hiding this comment.
Regenerating the Storybook snapshot removes Autocomplete.Root>Autocomplete.Popup from storybook/prop-description-allowlist.json. Could you include that one-line deletion so the snapshot check passes?
# Conflicts: # packages/ui/CHANGELOG.md
What?
Follow up to #86338 and #86520
Autocomplete.Inputnow throws an error in development when it is rendered insideAutocomplete.Popup. The error and a new JSDoc note onAutocomplete.Popuppoint to the pattern of an inlineAutocompleteinside a standalonePopovercomponent.Why?
#86338 put the search input of its special character picker inside an
Autocomplete.Popupthat stayed open. That inserted focus guards before the content, which shifted the block in the editor, and it caused focus trapping problems.Autocomplete.Popupis the suggestion list for an input outside it. A picker that opens from a button should render an inlineAutocompleteinside a standalonePopovercomponent, as theInlineInPopoverstory from #86520 shows. A development error catches this mistake when it is made, instead of relying only on docs.I think this is worth throwing an error, because not all cases fail in a noticeable way. And like we saw in the #86338 PR, a developer may fix it in a way that is both incomplete and increases complexity unnecessarily.
How?
Base UI's internals still handle an input inside the autocomplete popup, which
Comboboxdocuments as its "Input inside popup" pattern. ForAutocomplete, the docs shipped with Base UI 1.9.0 showed it only in a "Grid layout" emoji picker that opened fromAutocomplete.Trigger, and mui/base-ui#5636 has since removed that example and the "command pickers" usage guideline so that they do not read as officially supported.@wordpress/uidoes not exportTrigger, so this check rejects a composition that neither library documents forAutocomplete.Testing Instructions
<Autocomplete.Root open>with<Autocomplete.Input>inside<Autocomplete.Popup>.Autocomplete.Popupis for and points to an inlineAutocompleteinside a standalonePopovercomponent.Autocompletestories, including "Inline In Popover", and theMenuusage guidelines story. They render without errors.