3 ms·
I didn’t test this but won’t the focus-within trick work for click menus too? The user clicks the button (which must be a child of the container) so focus moves
by clord 6y ago
I didn’t test this but won’t the focus-within trick work for click menus too? The user clicks the button (which must be a child of the container) so focus moves within the container and hence the submenu can show.
nav:focus-within > .submenu {display:block}
(Edit: oh it’s mentioned in the article briefly without much explication of the need for js)
- layer8 6y agoIt’s okay for submenus to expand on hover, because the user is already mentally in a menu context if they clicked to open the top-level menu. That is common desktop behavior too. However, it’s preferable for the submenu to stay open until some other menu navigation takes place (e.g. a sibling submenu opens), because it’s much too easy to accidentally leave the submenu area with the pointer.