-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix dropdown destroy method #9381
Conversation
This fixes issue foundation#9339. When destroying a dropdown menu, the dropdown classes wouldn’t be removed if using a different class structure (for instance, using custom class names instead of `.menu`). Previous versions selected all child elements of the menu but on the latest version only direct `li` childs or elements with `.menu` class This commit ensures `ul` elements also get the classes removed, for those cases where custom classes are used.
Thanks for submitting a PR! You're right that it doesn't necessarily seem like the best way... the reason this was changed to be less broad-reaching was because folks were running into problems with nesting stuff inside menus. That said, looking at the rest of the Nest code there is already an assumption that uls are going to be submenus as a part of this menu. Hmm... the one thing I would raise then is that this will only work in the single-nested case, but deeply nested menus will still break. Given we have the Would be interested in thoughts from other @zurb/yetinauts on this as well. |
@kball So just |
That looks really ugly. Shouldn't the selector for finding do a lot less assumptions about the structure of the menu? |
I agree with @DaSchTour, we shouldn't target |
@ncoden I'd personally love to see the menu system redone, as its a bit of a nightmare to overwrite styles at the moment. That and get rid of table-cell, but thats another issue entirely 😉 |
@brettsmason I remember that on my previous project, I preferred reimplement a menu by myself rather than using the Foundation menu and overwriting everything. 😆 |
@ncoden relying on class names seems more problematic. I stumbled upon the problem because I'm building my own menu structure and class names using Foundation's mixins. So targeting a basic menu structure (lists) or just going back the previous way (selecting |
@diniscorreia I didn't mean that I thought about it, but I really don't know. I don't think I seen data attributes used for sub-elements before: (poke @kball) <ul data-menu class="menu">
<li data-menu-item class="menu-item">Item 1</li>
<li data-menu-item class="menu-item">Item 2</li>
...
</ul> Note: If we care about perf issues, we can use |
@ncoden from what I have heard recently the performance gap between class and attribute selector isn't that big and that there are a lot of operations that decrease performance a lot more. |
@DaSchTour I was talking generally. Anyway, the performance gap between classes and data attributes is for the browsers that don't support querySelector, so IE <= 8. My main concern is about using data attributes for the sub-elements of a component. 🤔 |
This gets to a really tricky line around how verbose we want to force the markup to be vs not, and it is something we're going to need to figure out moving forward... We have a couple of examples where we use data attributes on sub items before (magellan targets, equalizer watches)... We could start standardizing that. Another thing that we could consider (not sure if this is a good idea or not) is making it configurable via a javascript flag... e.g. for folks using the "default" approach we auto-apply the data attributes for children... this lets us have the 'base case' be still minimal markup. But if you want to do more complicated things or get more control, you set a 'data-manual-children' attribute on the parent and then you mark it up... making it easier to explicitly control component nesting etc. |
@kball 👍 totally agree |
@kball @DaSchTour @brettsmason So, what do we do for this PR ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I don't like having structure assomptions in the selector but (see the comments above) this is the way menu
works.
f3f24fe Fix dropdown destroy method Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
This fixes issue #9339. When destroying a dropdown menu, the dropdown classes wouldn’t be removed if using a different class structure (e.g.:, using custom class names instead of
.menu
). Previous versions selected all child elements of the menu, but on the latest version only directli
child elements or elements with.menu
class are targeted.This commit ensures
ul
elements also get the classes removed, for those cases where custom classes are used. Not sure if this is the best way, but seems to cover most cases.