Releases: ooade/react-click-away-listener
Add support for focus events
This is to ensure that the onClickAway
handler is fired whenever we focus on another element outside of the ClickAway component.
Thanks to @rishabh-ink for sending a PR for this! 🎉
BREAKING CHANGE: Handled Clickaway on the Cloned element
In this version, we no longer create an element and listen to the click and touchdown events whenever it's being triggered from anywhere on the document body excluding the element created.
Now, the event listener is being attached to the children with cloneElement
, and we ensured not to replace the children's ref, onClick
event and onTouchEnd
events while doing that.
Note: It will only break your existing app if you depend on the previous Clickaway component for styling or if you have other properties on the listener. But you if previously rendered it as a span and the only property added is onClickAway
, you can upgrade to the new version.
Shoutout to @jblevins1991 for suggesting this flow.
Clickaway on the cloned element
v2.0.0-alpha.0 Exclude children from interface
React Portal support
This version makes it possible to use Clickaway listener with React Portals! 🎉
Render Clickaway listener as a specified element
This allows users to pass an "as" property to the click away listener and have it rendered as such.
Thanks to @calebdeji for this! 🎉
Use other props passed to the Click Away Component
Just a few updates:
- Props were previously discarded when passed to the Click Away component but we've made it possible to treat the Click Away component as any regular div element. By doing that, it makes it possible to style or use it in any way you want without being gated to target the div from a parent element.
- Fixed our ESlint issue.
- Made sure to add a dependency array in our useEffect.
S/O to @Alphy11 for this release 🎉
Pass event to onClickAway callback
Passing the event in the callback ensures that you could make use of the event as you could do on every event handlers.
It makes it possible to do stuff like event.preventDefault()
and all.
Thanks to @Naismith for bringing it up and implementing! 🎉
The one with custom mouse events and touch events
Yeah, it's live. We now support:
- mouse events(click, mousedown, mouseup) and
- touch events(touchup, touchdown).
Breaking change as we switched from using mouseDown
to click
as the default mouse event.