Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Pressing enter opens additional modals #1187

Closed
ChrisRose opened this issue Oct 20, 2013 · 3 comments
Closed

Pressing enter opens additional modals #1187

ChrisRose opened this issue Oct 20, 2013 · 3 comments

Comments

@ChrisRose
Copy link

Pressing the enter key when a modal is open seems to open additional modal instances. I'm guessing this is a bug. If not, how do you disable?

@pkozlowski-opensource
Copy link
Member

Hmm, OK, I can see what you mean by cloning an example from the demo page, ex.:
http://run.plnkr.co/Tordcj787dsp1Ysi/

It can happen if you open a modal by clicking on the "Open me" button and then press enter. What is going on here is that the "Open me" button stays focused so pressing Enter invokes the same action once again. I'm not sure there is a way of preventing this, other than blurring an element in the click handler:
http://plnkr.co/edit/R49nrFNpNdQDcgVtV8yQ?p=preview

or setting autofocus on one of the modal buttons (probably better):
http://plnkr.co/edit/QTPabppP6GZYX21RP62z?p=preview

Not sure I can think of anything else as an work-around. I need to investigate if there is a way of preventing default behavior on all the events that are not targeting elements within the top-most modal window.

To be investigated / PRs welcomed!

@ehynds
Copy link

ehynds commented Jan 2, 2014

Perhaps document.activeElement could be blur()'d instead? This commit breaks the ability to use autofocus attributes inside of modal templates.

@chrisirhc
Copy link
Contributor

Instead of doing that, a more generic way would be to call focus into the window only if the focus (activeElement) isn't already on the window nor is it on any child elements of the window. However, I'm not sure if this is worthwhile for the added complexity.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants