Skip to content

Commit

Permalink
feature(a11y-dialog.js): change from event.which to event.key
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasvn committed Jun 8, 2022
1 parent 4d532f2 commit 901bac3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions a11y-dialog.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import focusableSelectors from 'focusable-selectors'

var TAB_KEY = 9
var ESCAPE_KEY = 27
var TAB_KEY = 'Tab'
var ESCAPE_KEY = 'Escape'

/**
* Define the constructor to instantiate a dialog
Expand Down Expand Up @@ -243,7 +243,7 @@ A11yDialog.prototype._bindKeypress = function (event) {
// is 'alertdialog', which should be modal
if (
this.shown &&
event.which === ESCAPE_KEY &&
event.key === ESCAPE_KEY &&
this.$el.getAttribute('role') !== 'alertdialog'
) {
event.preventDefault()
Expand All @@ -252,7 +252,7 @@ A11yDialog.prototype._bindKeypress = function (event) {

// If the dialog is shown and the TAB key is being pressed, make sure the
// focus stays trapped within the dialog element
if (this.shown && event.which === TAB_KEY) {
if (this.shown && event.key === TAB_KEY) {
trapTabKey(this.$el, event)
}
}
Expand Down

0 comments on commit 901bac3

Please sign in to comment.