Skip to content

Conversation

@bantic
Copy link
Contributor

@bantic bantic commented Jul 10, 2019

Adds a keyUp listener for 'Escape' that dismisses the shortcuts modal
when invoked.

Also fixes an unrelated inconsistency in quote style in the
keyboard-shortcuts component.

Esc seems to be a common shortcut for other modals (e.g. bootstrap and ember-modal-dialog).

Adds a keyUp listener for 'Escape' that dismisses the shortcuts modal
when invoked.

Also fixes an unrelated inconsistency in quote style in the
keyboard-shortcuts component.
}
}),

hideKeyboardShortcuts: on(keyUp('Escape'), function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this only trigger for this component or would this interfere with other esc listeners?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with ember-keyboard, but based on a read-through of their "priority" docs, my understanding is that this function will be called any time Esc is pressed while a) this {{docs-keyboard-shortcuts}} component is rendered and b) this component's keyboardActivated prop is true.

The ember-cli-addon-docs docs suggest rendering {{docs-keyboard-shortcuts}} in the application.hbs, and its keyboardActivated prop is set to true in its init, so for anyone who opts in to keyboard shortcuts it seems like yes, this callback function will be called on any docs page when Esc is pressed.

This is the case with all the other shortcuts already, though, and (again based on my reading of ember-keyboard docs) the keyup event's propagation won't be stopped, so it seems unlikely that it would interfere with any other keyup listeners on the page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bantic gotcha, this seems fine to me then

}
}),

hideKeyboardShortcuts: on(keyUp('Escape'), function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bantic gotcha, this seems fine to me then

@RobbieTheWagner RobbieTheWagner merged commit 245a69a into ember-learn:master Jul 31, 2019
@bantic bantic deleted the bantic/add-esc-key-shortcut branch July 31, 2019 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants