Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
891bda0c
Commit
891bda0c
authored
May 10, 2017
by
chikara-chan
Committed by
杨奕
Jun 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: keep focusing inside the popup by `tab` key
parent
d41c0c4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
12 deletions
+34
-12
src/utils/popup/popup-manager.js
src/utils/popup/popup-manager.js
+34
-12
No files found.
src/utils/popup/popup-manager.js
View file @
891bda0c
...
@@ -149,19 +149,41 @@ const PopupManager = {
...
@@ -149,19 +149,41 @@ const PopupManager = {
}
}
}
}
};
};
!
Vue
.
prototype
.
$isServer
&&
window
.
addEventListener
(
'
keydown
'
,
function
(
event
)
{
if
(
event
.
keyCode
===
27
)
{
// ESC
const
getTopPopup
=
function
()
{
if
(
PopupManager
.
modalStack
.
length
>
0
)
{
if
(
Vue
.
prototype
.
$isServer
)
return
;
const
topItem
=
PopupManager
.
modalStack
[
PopupManager
.
modalStack
.
length
-
1
];
if
(
PopupManager
.
modalStack
.
length
>
0
)
{
if
(
!
topItem
)
return
;
const
topPopup
=
PopupManager
.
modalStack
[
PopupManager
.
modalStack
.
length
-
1
];
const
instance
=
PopupManager
.
getInstance
(
topItem
.
id
);
if
(
!
topPopup
)
return
;
if
(
instance
.
closeOnPressEscape
)
{
const
instance
=
PopupManager
.
getInstance
(
topPopup
.
id
);
instance
.
handleClose
?
instance
.
handleClose
()
return
instance
;
:
(
instance
.
handleAction
?
instance
.
handleAction
(
'
cancel
'
)
:
instance
.
close
());
}
};
if
(
!
Vue
.
prototype
.
$isServer
)
{
// handle `esc` key when the popup is shown
window
.
addEventListener
(
'
keydown
'
,
function
(
event
)
{
if
(
event
.
keyCode
===
27
)
{
const
topPopup
=
getTopPopup
();
if
(
topPopup
&&
topPopup
.
closeOnPressEscape
)
{
topPopup
.
handleClose
?
topPopup
.
handleClose
()
:
(
topPopup
.
handleAction
?
topPopup
.
handleAction
(
'
cancel
'
)
:
topPopup
.
close
());
}
}
}
}
}
});
});
// keep focusing inside the popup by `tab` key
document
.
addEventListener
(
'
focusin
'
,
function
(
event
)
{
const
topPopup
=
getTopPopup
();
if
(
topPopup
&&
!
topPopup
.
$el
.
contains
(
event
.
target
))
{
event
.
stopPropagation
();
topPopup
.
$el
.
focus
();
}
});
}
export
default
PopupManager
;
export
default
PopupManager
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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