@@ -186,7 +186,7 @@ H5P.init = function (target) {
186
186
instance . triggerXAPI ( 'accessed-reuse' ) ;
187
187
} ) ;
188
188
actionBar . on ( 'copyrights' , function ( ) {
189
- var dialog = new H5P . Dialog ( 'copyrights' , H5P . t ( 'copyrightInformation' ) , copyrights , $container , $actions . find ( '.h5p-copyrights' ) [ 0 ] ) ;
189
+ var dialog = new H5P . Dialog ( 'copyrights' , H5P . t ( 'copyrightInformation' ) , copyrights , $container ) ;
190
190
dialog . open ( true ) ;
191
191
instance . triggerXAPI ( 'accessed-copyright' ) ;
192
192
} ) ;
@@ -1040,11 +1040,12 @@ H5P.t = function (key, vars, ns) {
1040
1040
* @param {H5P.jQuery } $element
1041
1041
* Which DOM element the dialog should be inserted after.
1042
1042
* @param {H5P.jQuery } $returnElement
1043
- * Which DOM element the focus should be moved to on close
1043
+ * Which DOM element the focus should be moved to on close
1044
1044
*/
1045
1045
H5P . Dialog = function ( name , title , content , $element , $returnElement ) {
1046
1046
/** @alias H5P.Dialog# */
1047
1047
var self = this ;
1048
+ this . activeElement = document . activeElement ;
1048
1049
var $dialog = H5P . jQuery ( '<div class="h5p-popup-dialog h5p-' + name + '-dialog" aria-labelledby="' + name + '-dialog-header" aria-modal="true" role="dialog" tabindex="-1">\
1049
1050
<div class="h5p-inner">\
1050
1051
<h2 id="' + name + '-dialog-header">' + title + '</h2>\
@@ -1109,6 +1110,9 @@ H5P.Dialog = function (name, title, content, $element, $returnElement) {
1109
1110
if ( $returnElement ) {
1110
1111
$returnElement . focus ( ) ;
1111
1112
}
1113
+ else if ( self . activeElement ) {
1114
+ self . activeElement . focus ( ) ;
1115
+ }
1112
1116
else {
1113
1117
$element . focus ( ) ;
1114
1118
}
0 commit comments