You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently used the Reach-ui comboxbox in a modal and noticed that using escape to close the popover also closed the modal. I thought "no problem" and slapped in a stopPropagation in an event listener and moved on.
The trouble came when I tried to test this behavior. I expected that when I did fireEvent.keyDown(query('input'), {key: 'Escape'}) without the stopPropagation in my test, the modal would close. Sadly it didn't close, making it seem as if the stopPropagation was not needed. However this works in the browser and is indeed needed!
Does anyone have any ideas as to why I might be able to close a modal with the escape key in the browser, but not in a test? I also noticed that there isn't a test for closing the popover with escape in the Reach-ui combobox tests, so I wondered if ya'll had run into a similar issue.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I recently used the Reach-ui comboxbox in a modal and noticed that using escape to close the popover also closed the modal. I thought "no problem" and slapped in a
stopPropagation
in an event listener and moved on.The trouble came when I tried to test this behavior. I expected that when I did
fireEvent.keyDown(query('input'), {key: 'Escape'})
without thestopPropagation
in my test, the modal would close. Sadly it didn't close, making it seem as if thestopPropagation
was not needed. However this works in the browser and is indeed needed!Does anyone have any ideas as to why I might be able to close a modal with the escape key in the browser, but not in a test? I also noticed that there isn't a test for closing the popover with escape in the Reach-ui combobox tests, so I wondered if ya'll had run into a similar issue.
Beta Was this translation helpful? Give feedback.
All reactions