theKashey / react-focus-on

🎯 Solution for WAI ARIA compatible modal dialogs or full-screen tasks, you were looking for
MIT License
336 stars 14 forks source link

`onClickOutside` doesn't trigger on iOS #13

Closed benoitgrelard closed 5 years ago

benoitgrelard commented 5 years ago

Hi @theKashey,

Whilst implementing a modal dialog using react-focus-on I have realised that the onClickOutside callback doesn't get triggered on iOS (possibly all touch devices?)

I have done some investigation and I saw that the lib attaches a click handler on the document in Effect.tsx (here).

However, after some investigation, it appears iOS doesn't trigger any click events on nodes unless they "look" clickable (see this comment).

I have a fix for it (basically attaching a touchstart handler on top of the click handler). I will send you a PR and we can continue the discussion there.

✌️