-
Notifications
You must be signed in to change notification settings - Fork 35
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
Allow multiple triggers to modify a single toggle-able node #105
Comments
Hi @aaronstezycki 👋 I see your problem, here. Since the behaviour is to toggle classes, if you have two different triggers that target the same element, toggling the same classname, you'll have a conflict. I would probably think about a way to link triggers. In your example, I tried to fix the problem, and it seems you can have a acceptable behaviour by adding |
With both triggers, or any trigger for that matter, you could have a query function which checks whether the target has the class on it already... then if it has the class already remove the class (or classes) or if it doesn't have the class, add the class on to target. I'm willing to bet this would solve a few different problems that the library might suffer from? I'll check to see if your solution works in the meantime, altho maybe creating a different data attribute name to solve this use case might be preferable. |
Well, I have already think about such a behaviour, but it can't work since the developer can add whatever classes he wants by default, so on toggling, a trigger or a target can have some and don't have others. The behaviour is to toggle, and not arbitrary choice what to do with the classes that can be already set. So I think that yes, I may add a new attribute to create a link between triggers. |
I agree @Twikito, an attribute would be in order, since there is more going on besides classes, we need to swap ARIA attributes as well properly. My use-case are tabs that become accordion on narrow screens. But I have options, like https://css-tricks.com/transformer-tabs/ |
I've just tried this approach and un-fortunately it has some unwanted side effects. :( |
Is your feature request related to a problem? Please describe.
Allowing multiple triggers to interact with the same toggle-able element would be very welcome. For example, a main navigation trigger/button might toggle a modal or 'sidebar' into view. Being able to click on a body link/button trigger to open the same 'sidebar' would allow users the flexibility of which trigger to use to access the modal.
Describe the solution you'd like
Something like ...
Note: This would also need to work with radio group based triggers. (This is the specific use case I need)
I don't have the time to put together a reduced test case at the minute, but would like to when I have time. This is a great library, and I'd love to see it improve further to solve more edge cases.
The text was updated successfully, but these errors were encountered: