Pomax / react-onclickoutside

An onClickOutside wrapper for React components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can't use outsideClickIgnoreClass with multiple class names

orenraz opened this issue · comments

will be great to be able to pass multiple class names for outsideClickIgnoreClass like:
outsideClickIgnoreClass="class-a class-b".

you can change the function isNodeFound to check for multiple appearance of classes

commented

can you explain the use case?

commented

I'm not sure I understand. Are you saying these apps exist inside the modal? If so, clicks will already originate inside the modal and outside clicks shouldn't even be detected (because there are none). If they're not, then why can you not add the outsideclickignore class to both dropdowns' class list? You're not stuck with "one class" for elements, just say <Dropdown1 class="your classes outsideclickignore" ...> and <Dropdown2 class="other stuff outsideclickignore" ...> and now clicks on either of those drop downs won't trigger the outsideclick handler.

commented

That's a better explanation of the situation. I'm pretty sure that's a valid use case for allowing "one of any" ignore classes rather than just a single fixed string

I have the same situation, and I am looking forward to be able to pass multiple class names for outsideClickIgnoreClass.

Me too. I have the same situation, and I am looking forward to be able to pass multiple class names for outsideClickIgnoreClass.

In UI, we can imagine that some elements are inside their same parent element. but in DOM, they are placed in different places.

Not for every case, but instead of passing multiple classes to outsideClickIgnoreClass you could try "lifting things up" by wrapping the required elements into a single parent element which you then ignore.