stimulus-components / stimulus-reveal-controller

A Stimulus controller to toggle a class on one or multiple items to show or hide them.
https://stimulus-reveal-controller.stimulus-components.com
MIT License
27 stars 5 forks source link

Close when clicking away #7

Closed tmaier closed 2 years ago

tmaier commented 2 years ago

It would be great, if this controller would allow to close when the use clicks away.

How are others solving this? https://www.npmjs.com/package/stimulus-reveal has a `data-reveal-away-value` attribute
guillaumebriday commented 2 years ago

I think you can achieve this with a classic event listener on document or window.

See https://stimulus.hotwired.dev/reference/actions#global-events