focus after dialog shown
This commit is contained in:
Родитель
3e8d0caf34
Коммит
2857929274
|
@ -218,7 +218,7 @@
|
|||
if (!dialogPolyfill.dm.pushDialog(this)) {
|
||||
throw new Error('Failed to execute \'showModal\' on dialog: There are too many open modal dialogs.');
|
||||
}
|
||||
this.show();
|
||||
this.setOpen(true);
|
||||
this.openAsModal_ = true;
|
||||
|
||||
// Optionally center vertically, relative to the current viewport.
|
||||
|
@ -233,6 +233,9 @@
|
|||
this.backdrop_.addEventListener('click', this.backdropClick_);
|
||||
this.dialog_.parentNode.insertBefore(this.backdrop_,
|
||||
this.dialog_.nextSibling);
|
||||
|
||||
// Focus on whatever inside the dialog.
|
||||
this.focus_();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
20
suite.js
20
suite.js
|
@ -332,6 +332,26 @@ void function() {
|
|||
assert.notEqual(document.activeElement, input,
|
||||
'parent focus should not be restored');
|
||||
});
|
||||
test('don\'t scroll anything into focus', function() {
|
||||
// https://github.com/GoogleChrome/dialog-polyfill/issues/119
|
||||
|
||||
var div = cleanup(document.createElement('div'));
|
||||
document.body.appendChild(div);
|
||||
|
||||
var inner = document.createElement('div');
|
||||
inner.style.height = '10000px';
|
||||
div.appendChild(inner);
|
||||
|
||||
div.appendChild(dialog);
|
||||
|
||||
var input = cleanup(document.createElement('input'));
|
||||
input.type = 'text';
|
||||
dialog.appendChild(input);
|
||||
|
||||
assert.equal(document.documentElement.scrollTop, 0);
|
||||
dialog.showModal();
|
||||
assert.equal(document.documentElement.scrollTop, 0);
|
||||
});
|
||||
});
|
||||
|
||||
suite('top layer / inert', function() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче