Commit 403f55fb authored by Pierre-Denis Vanduynslager's avatar Pierre-Denis Vanduynslager
Browse files

Fix spacebar key in Firefox for button elements

parent 1cdd0d16
Showing with 4 additions and 4 deletions
+4 -4
...@@ -28,7 +28,7 @@ const Dropdown = (($) => { ...@@ -28,7 +28,7 @@ const Dropdown = (($) => {
const ARROW_UP_KEYCODE = 38 // KeyboardEvent.which value for up arrow key const ARROW_UP_KEYCODE = 38 // KeyboardEvent.which value for up arrow key
const ARROW_DOWN_KEYCODE = 40 // KeyboardEvent.which value for down arrow key const ARROW_DOWN_KEYCODE = 40 // KeyboardEvent.which value for down arrow key
const RIGHT_MOUSE_BUTTON_WHICH = 3 // MouseEvent.which value for the right button (assuming a right-handed mouse) const RIGHT_MOUSE_BUTTON_WHICH = 3 // MouseEvent.which value for the right button (assuming a right-handed mouse)
const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEYCODE}|${ARROW_DOWN_KEYCODE}|${ESCAPE_KEYCODE}|${SPACE_KEYCODE}`) const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEYCODE}|${ARROW_DOWN_KEYCODE}|${ESCAPE_KEYCODE}`)
const Event = { const Event = {
HIDE : `hide${EVENT_KEY}`, HIDE : `hide${EVENT_KEY}`,
...@@ -213,7 +213,7 @@ const Dropdown = (($) => { ...@@ -213,7 +213,7 @@ const Dropdown = (($) => {
} }
static _dataApiKeydownHandler(event) { static _dataApiKeydownHandler(event) {
if (!REGEXP_KEYDOWN.test(event.which) || if (!REGEXP_KEYDOWN.test(event.which) && /button/i.test(event.target.tagName) && event.which === SPACE_KEYCODE ||
/input|textarea/i.test(event.target.tagName)) { /input|textarea/i.test(event.target.tagName)) {
return return
} }
...@@ -228,8 +228,8 @@ const Dropdown = (($) => { ...@@ -228,8 +228,8 @@ const Dropdown = (($) => {
const parent = Dropdown._getParentFromElement(this) const parent = Dropdown._getParentFromElement(this)
const isActive = $(parent).hasClass(ClassName.SHOW) const isActive = $(parent).hasClass(ClassName.SHOW)
if (!isActive && event.which !== ESCAPE_KEYCODE || if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) ||
isActive && event.which === ESCAPE_KEYCODE) { isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) { if (event.which === ESCAPE_KEYCODE) {
const toggle = $(parent).find(Selector.DATA_TOGGLE)[0] const toggle = $(parent).find(Selector.DATA_TOGGLE)[0]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment