Repository navigation
Conversation
🤖 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. Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +6.88 kB (+0.08%) Total Size: 8.66 MB 📦 View Changed
From ⚡ 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
From |
…issal # Conflicts: # packages/ui/CHANGELOG.md # packages/ui/src/form/primitives/autocomplete/root.tsx # packages/ui/src/form/primitives/combobox/root.tsx # packages/ui/src/utils/use-iframe-dismissal-bridge.ts
ciampo
left a comment
There was a problem hiding this comment.
Should we leave another comment on the open Base UI issue covering this gap with these form-control cases?
|
There is so much to work around and we haven't even squashed all the known limitations yet. I really hope this is addressed upstream 😅 |
|
Should we consider opening a PR upstream? |
| ( event: Event ) => { | ||
| const eventTarget = event.target as Node | null; | ||
| if ( | ||
| trigger && | ||
| popup && | ||
| getNodeDocument( eventTarget ) !== popup.ownerDocument && | ||
| ! trigger.contains( eventTarget ) && | ||
| ! isInsideCurrentPopup( event, trigger ) | ||
| ) { | ||
| dispatchOutsidePress( event, popup.ownerDocument ); |
There was a problem hiding this comment.
When two popups stay open in different documents, their bridges keep sending events back to each other. Could we mark events created by a bridge so other bridges don't forward them again?
Reproduction and evidence kindly provided by my agent
- Render two non-modal Selects with triggers in the parent document and popups portaled into separate same-origin iframes.
- Have the first Select cancel close requests through
eventDetails.cancel(). - Open both Selects through their triggers.
- Clear the observation counters, then click a button in a third same-origin iframe.
Chromium reported 43 forwarded pointerdown events, 23 close callbacks for the first Select, and 21 for the second. The probe uses the actual pinned Select components and native browser clicks. These counts were collected without a recursion cutoff.
|
This PR, as well as the existing What if we did something more minimal: the essence of the patch is that we listen for events inside the iframe document, and forward them to the outer Does it cause any new issues? If we indiscriminately forward the needed events ( |
Implemented the idea here: #85263. Let's see if it really works. |
|
Closing in favor of #85263 |
What?
Follow up to #83509
Non-modal
Select,Combobox, andAutocompletepopups close when a user clicks or taps inside a same-origin iframe outside the popup, while the iframe receives that interaction. This also coversSelectControlwithmodal={ false }and searchable controls built onCombobox.Why?
Base UI listens for outside presses in the popup document. Pointer events inside an iframe do not reach that document. The existing bridge handles
MenuandPopover, but form roots need Base UI to report dismissal through their normalonOpenChangepath.How?
useIframePressListenersshares iframe event observation between the two adapters.useIframeDismissalWithCloseActionpreserves the existingMenuandPopoverbehavior by calling their close action.useIframeOutsidePressForwardingforwards pointer, compatibility mouse-down, and click events to the containing iframe element in the trigger document, allowing Base UI to dismiss form popups with its normaloutside-pressreason. Forwarding the compatibility mouse-down event preserves Select dismissal for touch taps. Both adapters share the popup containment check from #83870.This fix covers form compositions whose trigger and popup share a document. Compositions split across documents are outside this PR's scope.
Like the existing bridge, this one discovers its trigger from an opening interaction. Popups opened only through
defaultOpenor an externalopenchange are a separate follow-up.Testing Instructions
Select,Combobox, orAutocompletenext to a same-origin iframe containing a button. Open the popup and click the iframe button. The popup should close on the first click and the button should receive it once.SelectControlwithmodal={ false }.SelectControl. Its backdrop should close the popup and consume the first click.Screenshots or screencast
The iframe button receives all three mouse clicks in each recording. Before this fix, the popups stay open. After this fix, they close.
Before fix
iframe-dismissal-before.mp4
After fix
iframe-dismissal-after.mp4