Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
403f55fb
Commit
403f55fb
authored
8 years ago
by
Pierre-Denis Vanduynslager
Browse files
Options
Download
Email Patches
Plain Diff
Fix spacebar key in Firefox for button elements
parent
1cdd0d16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/src/dropdown.js
+4
-4
js/src/dropdown.js
with
4 additions
and
4 deletions
+4
-4
js/src/dropdown.js
+
4
-
4
View file @
403f55fb
...
@@ -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
]
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment