Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
4cd3927c
Commit
4cd3927c
authored
Oct 03, 2017
by
jun
Browse files
MDL-59858 amd: Focus on the element that actually triggers the modal
parent
159b4e5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/amd/build/modal_factory.min.js
View file @
4cd3927c
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
lib/amd/src/modal_factory.js
View file @
4cd3927c
...
...
@@ -63,12 +63,15 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
*/
var
setUpTrigger
=
function
(
modalPromise
,
triggerElement
)
{
if
(
typeof
triggerElement
!=
'
undefined
'
)
{
// The element that actually shows the modal.
var
actualTriggerElement
=
null
;
if
(
Array
.
isArray
(
triggerElement
))
{
var
selector
=
triggerElement
[
1
];
triggerElement
=
triggerElement
[
0
];
CustomEvents
.
define
(
triggerElement
,
[
CustomEvents
.
events
.
activate
]);
triggerElement
.
on
(
CustomEvents
.
events
.
activate
,
selector
,
function
(
e
,
data
)
{
actualTriggerElement
=
e
.
currentTarget
;
modalPromise
.
then
(
function
(
modal
)
{
modal
.
show
();
...
...
@@ -79,6 +82,7 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
}
else
{
CustomEvents
.
define
(
triggerElement
,
[
CustomEvents
.
events
.
activate
]);
triggerElement
.
on
(
CustomEvents
.
events
.
activate
,
function
(
e
,
data
)
{
actualTriggerElement
=
e
.
currentTarget
;
modalPromise
.
then
(
function
(
modal
)
{
modal
.
show
();
...
...
@@ -90,7 +94,10 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal',
modalPromise
.
then
(
function
(
modal
)
{
modal
.
getRoot
().
on
(
ModalEvents
.
hidden
,
function
()
{
triggerElement
.
focus
();
// Focus on the trigger element that actually launched the modal.
if
(
actualTriggerElement
!==
null
)
{
actualTriggerElement
.
focus
();
}
});
return
modal
;
...
...
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