-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
@wordpress/components
: portal behavior of popover-based components
#63697
Comments
Quick side question: What are we hoping to gain in terms of UX by switching some of these low level components to ariakit? |
Here are my thoughts:
I think that
All popover-based components could expose two props, mimicking
I think that the popover-based components should not use Keeping The const slotElemement = useSlot( slotName );
// ...
return ( <PopoverBasedComponent portalElement={ slotElemement } /> ); The
One limitation of current popover-based components is caused by the fact that they rely on their If all components get appended to the Having said that, there may be instances in which a
We may have to retain the One thing to keep in mind is that both |
There are a few reasons, but specifically to the UX side, using a headless component library (in this case,
|
Thanks for opening the discussion, @ciampo 🙌
I agree with all your suggestions:
|
@ciampo Thanks for the details Marco. Those are good reasons but nothing clear on the UX side. I'd love if we can focus more on unlocking more UX improvements from our components and refactoring as a mean not as a goal. |
@youknowriad we are definitely aligned on this, the main goal of all of this work is to ultimately provide a better UX for our users! These specific conversations that we're having right now about modality and portals are more of a consequence/opportunity of using ariakit and are quite technical, but they could also have UX implications, for example in avoiding issues like this one, this one, or this one. Having more components based on the same underlying headless component library (for example, ariakit) gives us several advantages that, in my opinion, all contribute to a better UX all around:
With this in mind, the above examples can be considered improvements on the UX side. |
Context
@wordpress/components
: modality of popover-based components #63674As we're re-writing some of the components in the
@wordpress/components
package to useariakit
, we have the chance to re-discuss our approach to architecting our APIs and the behavior of such components.More specifically, as we're working on the new version of
DropdownMenu
andCustomSelectControl
, one of the aspects that we should discuss and agree on at a package level is where in the DOM popover-based components should render.This is, at the time of writing, the behavior of the first-party
Popover
component (and all components based on it) with regards to where it renders in the DOM:inline
prop istrue
, it renders inline (ie. in the same DOM tree as its parent React component); otherwise,__unstableSlotNameProvider
React context (code);__unstableSlotName
__unstableSlotName
is not set, it renders in thePopover.Slot
;useSlot
hook, it fallbacks to rendering in adiv.components-popover__fallback-container
appended to thedocument.body
.This behavior can be changed via the
__unstableSlotNameProvider
context and__unstableSlotName
prop (to pick another slot), and theinline
prop (when set totrue
, the popover will render inline instead of in a slot).Note
Slot is a Gutenberg-specific term and refers to the
SlotFill
APIs, a technology that exposes React'sportal
functionality as a set of React components. You can read more about it in this article, or you consult the official docs and the Storybook examples.Using
ariakit
allows us to easily tweak, if necessary, this aspect for popover-based components (popover, tooltips, dropdowns, dropdown menus, dialogs, selects, comboboxes...) via theportal
andportalElement
props.This topic was partially discussed in a related issue, where an initial consensus was reached on changing the default behavior of the
Popover
component to append todocument.body
by default.What
Now that we're adding a new set of
ariakit
-based components, we have the chance of making changes to the behaviors explained above.Therefore, we need to decide:
SlotFill
APIs?Popover
from this package?cc @WordPress/gutenberg-components
The text was updated successfully, but these errors were encountered: