Try using Popover API to implement responsive navigation menu instead of using Interactivity API#63917
Try using Popover API to implement responsive navigation menu instead of using Interactivity API#63917westonruter wants to merge 1 commit intotrunkfrom
Conversation
|
Size Change: -261 B (-0.01%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
More explanation about the |
|
Also, it would be trivial to implement a polyfill for Invoker Commands for browsers that don't support it yet. In this way, we could go ahead and ship the use of |
|
I'll likely be closing this PR in favor of @stokesman's PR #69720. |
|
@westonruter There's also #68755, so we may want to compare the approaches and scope of the changes between that and #69720. In my PR (which admittedly is so far just experimental), I'm using popover for both the navigation overlay (by default only used on mobile) and for submenus (across all viewports). One thing to call out is that unfortunately the Interactivity API implementation for the overlay and submenus is very intertwined - maybe this was done to reduce some code to write, but to me that doesn't look like a good choice because there are so many subtle nuances in different behavior. And now it makes decoupling more painful than it should be. This is partly the reason why I think we need to consider changing both the overlay and the submenus implementation together. Because if you only change one of them to use popover or dialog, most of the Interactivity API code will still stick around for the other one. |
|
See #69720 |
In Core-50182, I commented:
This PR attempts to replace the use of the Interactivity API with the native Popover API instead. It was pretty easy to implement, however there is one key problem: there is no focus trap for popovers since they are non-modal. In contrast, the
dialogelement is a modal, but it currently requires opening with JavaScript. See comparison of dialog vs popover. In order to leverage this, I believe we have to wait for invoker commands to land in the web platform. See also An update on invokers: Invoker commands in HTML.Screenshots or screencast
Screen.recording.2024-07-24.17.56.31.webm