Only focus button if menu wasn’t hidden already

This commit is contained in:
Sam Potts
2018-08-01 01:38:57 +10:00
parent c8db1e55dd
commit aaa56caa9c
5 changed files with 9 additions and 7 deletions

5
src/js/controls.js vendored
View File

@ -1085,7 +1085,8 @@ const controls = {
}
// True toggle by default
let show = is.element(popup) && popup.hasAttribute('hidden');
const hidden = popup.hasAttribute('hidden');
let show = hidden;
if (is.boolean(input)) {
show = input;
@ -1124,7 +1125,7 @@ const controls = {
setFocus.call(this, firstItem, true);
}
// If closing, re-focus the button
else if (!show) {
else if (!show && !hidden) {
setFocus.call(this, button, is.keyboardEvent(input));
}
},