feat: Add automatic dropdown positioning#1014
Conversation
|
Hi there! 👋 Thank you for your contribution to the FIP Guide! 🚀 Checklist before merging:
|
✅ Deploy Preview for fipguide ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi @MoritzWeber0 thank you for your implemenation :) |
It should only appear if the scrollbar is necessary and the content would overflow otherwise, which does happen on browser viewports with < 520px height. There are workarounds to hide scrollbars, but usually they are not really recommended as it also overwrites the system preferences regarding scrollbars. The default on Windows is to show the scrollbar, while on Android or macOS this isn't the case. |
therobrob
left a comment
There was a problem hiding this comment.
Thank you Moritz – this is a cool new feature; it's just a bit complicated to figure out at first. :)
One question: the language switcher has o-dropdown__menu--above AND o-dropdown__menu--right at once. Is this correct? The properties are conflicting.
Unfortunately #1037 isn‘t solved by this PR, but we can address it in a separate PR.
# Conflicts: # layouts/_partials/nav-dropdown.html
There was a problem hiding this comment.
Should we change these to .id here as well, just like in nav-dropdown partial?
There was a problem hiding this comment.
Since the ids are just the identifiers of the operators here, the risk of the same id used somewhere else might be higher. But since the dropdown is the only place where the anchors are used, I'd be fine with it.
Or we use the same as the id of the element, in this case "{{ $id }}-button"? The is should be unique anyway. What do you think?
There was a problem hiding this comment.
Maybe we're talking at cross-purposes.
In line 1 we already initialize $id := .id, so in L 12 and 30 we can use .id instead, couldn’t we?
I'll check it later.
👍 |
It's correct that the language switcher has both. One does define the horizontal positioning and one does the vertical alignment ( What wasn't correct is that the |
Okay got it; but why does the navbar-dropdown-menu just have |

Use the new anchor and position-try systems in CSS, available since January in all major browsers to automatically position the dropdown menu.
For horizontal positioning, automatically shift the dropdown menu to the left if there is not enough space on the screen. For vertical positioning, use scrolling to handle the overflow.
Resolves #1013