-
-
Notifications
You must be signed in to change notification settings - Fork 848
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Nested menus/submenus #620
Comments
I've explored the popper.js library some more, and i think i've found some interesting stuff: It seems like the calculation of the coordinates is a combination of multiple values from the position of the trigger and its parent. Moving the dropdown to the left of the viewport moves the popover with the same distance. This applies to both the X and Y axis: I've attached a video here showing it in action. I feel like the popovers position is based on a combination of the trigger and its parent (the initial trigger button), but this is just a hypothesis. I do not have time to look deep into the source code of both projects to determine what the exact behaviour is. Screen.Recording.2021-12-15.at.12.32.25.movHere is the repo i have played around with: https://github.com/MathiasWP/dropdown-hoist-bug-demo Having this feature has become important for our startup-company, but i do not have time myself to find a solution right now. Would you be able to look into this, @claviska? I am willing to donate some of my own money to support you and this great project - if that can help. |
I wouldn't use the approach you described above because, even if you get positioning nailed down, it requires an additional click to open the submenu and keyboard interactions won't work as users expect. To do this correctly, some work needs to be done in I think using the same Here's an example of FAST's menu which does this well: https://jsfiddle.net/7qvzjcpe/ From the fiddle: <fast-menu>
<fast-menu-item>Menu item 1<fast-menu slot="submenu">
<fast-menu-item>Menu item 1.1</fast-menu-item>
<fast-menu-item>Menu item 1.2</fast-menu-item>
<fast-menu-item>Menu item 1.3</fast-menu-item>
</fast-menu>
</fast-menu-item>
<fast-menu-item>Menu item 2<fast-menu slot="submenu">
<fast-menu-item>Menu item 2.1</fast-menu-item>
<fast-menu-item>Menu item 2.2</fast-menu-item>
<fast-menu-item>Menu item 2.3</fast-menu-item>
</fast-menu>
</fast-menu-item>
<fast-menu-item>Menu item 3<fast-menu slot="submenu">
<fast-menu-item>Menu item 3.1</fast-menu-item>
<fast-menu-item>Menu item 3.2</fast-menu-item>
<fast-menu-item>Menu item 3.3</fast-menu-item>
</fast-menu>
</fast-menu-item>
</fast-menu> This isn't top of my radar, but it's a valid request and I'd like to add support to it. I just can't guarantee a time right now. |
Thank you for answering! I still mean that there are valid use cases where it makes sense to have nested dropdowns, even if it requires an additional click to open. Look at the example above from Notions menu. The It would be very useful for us to have this feature asap, could we maybe discuss ways to move this feature higher up on your radar? 😄 |
Ah, yeah we're talking about two different things. Sorry for the confusion! Regarding your CodePen, the reason it happens when you use I consider this a gap in the platform. It's one that many are aware of and there are proposals to resolve it. One is a CSS property (suggested by me) and another is an HTML Element. As such, I don't think this is something we can "fix." The I'm aware that's not great news for you. Have you considered the alternative approach of reworking your overflows so you don't have to use |
No worries, thank you for the answer! I agree that it is a gap in the platform, but isn't that what popper.js is trying to solve with the I may be missing something in my intuition, so feedback is appreciated. |
This is a Request For Comments to seek directional guidance towards implementing the submenu slot of menu-item. Includes: - SubmenuController to manage event listeners on menu-item. - Example usage in menu-item documentation. - Trivial tests to check rendering. Outstanding questions include: - Accessibility concerns. E.g. where to handle 'ArrowRight', 'ArrowLeft'? - Should selection of menu-item denoting submenu be possible or customizable? - How to parameterize contained popup? - Implementation concerns: - Use of ref / id - delegation of some rendering to the controller - What to test Related to [shoelace-style#620](shoelace-style#620).
This may be a different feature request, but for our use cases the ability to have a collapsible indented menu would be more the behavior we need from a submenu.
I could potentially spend some time implementing this if we can agree on what behavior the library should have out of the box. |
* [RFC] Proof-of-concept commit for submenu support This is a Request For Comments to seek directional guidance towards implementing the submenu slot of menu-item. Includes: - SubmenuController to manage event listeners on menu-item. - Example usage in menu-item documentation. - Trivial tests to check rendering. Outstanding questions include: - Accessibility concerns. E.g. where to handle 'ArrowRight', 'ArrowLeft'? - Should selection of menu-item denoting submenu be possible or customizable? - How to parameterize contained popup? - Implementation concerns: - Use of ref / id - delegation of some rendering to the controller - What to test Related to [#620](#620). * Update submenu-controller.ts Removed extraneous `console.log()`. * PoC working of ArrowRight to focus on submenu. * Revert "PoC working of ArrowRight to focus on submenu." (Didn't mean to publish this.) This reverts commit be04e9a. * [WIP] Submenu WIP continues. - Submenus now close on change-of-focus, not a timeout. - Keyboard navigation support added. - Skidding fix for better alignment. - Submenu documentation moved to Menu page. - Tests for accessibility, right and left arrow keys. * Cleanup: Removed dead code and dead code comments. * style: Eslint warnings and errors fixed. npm run verify now passes. * fix: 2 changes to menu / submenu on-click behavior: 1. Close submenu on click explicitly, so this occurs even if the menu is not inside of an sl-dropdown. 2. In menu, ignore clicks that do not explicitly target a menu-item. Clicks that were on (e.g. a menu-border) were emitting select events. * fix: Prevent menu's extraneous Enter / space key propagation. Menu's handleKeyDown calls item.click (to emit the selection). Propagating the keyboard event on Enter / space would the cause re-entry into a submenu, so prevent the needless propagation. * Submenu tweaks ... - 100 ms delay when opening submenus on mouseover - Shadows added - Distance added to popup to have submenus overlap menu slightly. * polish up submenu stuff * stay highlighted when submenu is open * update changelog * resolve feedback --------- Co-authored-by: Bryce Moore <[email protected]>
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the bug
We are frequently using the sl-dropdown component for dropdowns. We have some use cases where it would be preferable to show a new dropdown within a dropdown. The problem/bug we are trying to solve is to use the hoist-property on the inner-most dropdown. The position of the inner dropdowns content does not match the trigger when hoist is set.
To Reproduce
See codepen below.
Demo
https://codepen.io/MathiasWP/pen/VwMpvWz
Screenshots
Browser / OS
Additional information
I've tried to get a better understanding of how the dropdown-component works by reading through the source code. I see that the popover is created with the popper.js library, and that setting the
host
property is equal to setting the strategy tofixed
. The thing that puzzles me is that in the popper.js documentation, they say that "If your reference element is in a fixed container, use the fixed strategy". My understanding of the popper.js library is that they usegetBoundingClientRect
to calculate coordinates, so i don't quite understand why this bug occurs.The text was updated successfully, but these errors were encountered: