davidtheclark / react-aria-modal

A fully accessible React modal built according WAI-ARIA Authoring Practices
http://davidtheclark.github.io/react-aria-modal/demo/
MIT License
1.03k stars 96 forks source link

How to handle ESC key press for components rendered inside the modal? #72

Closed jknanda78 closed 5 years ago

jknanda78 commented 5 years ago

Hello,

I have a menu component that will close on ESC keypress. But while doing that the modal gets closed.

Is there a way to handle ESC keypress for components (rendered inside the modal) without closing the modal? Something out of the box?

Thanks in advance.

davidtheclark commented 5 years ago

Have you tried event.stopPropagation() on the escape event you capture for you menu?

jknanda78 commented 5 years ago

I did try and it worked. But I thought if the solution could be available from your component.

Thanks.

davidtheclark commented 5 years ago

Thanks @jknanda78. I think e.stopPropagation() is the standard way to do this, and I don't know of anything we could do from this component to make it easier than that.