chore: use focusout instead of blur which does not bubble

This commit is contained in:
Joren Broekema 2020-10-28 12:46:51 +01:00
parent 65d0cf9f80
commit bc97030fed
2 changed files with 3 additions and 3 deletions

View file

@ -132,13 +132,13 @@ export function containFocus(rootElement) {
function disconnect() { function disconnect() {
window.removeEventListener('keydown', handleKeydown); window.removeEventListener('keydown', handleKeydown);
window.removeEventListener('focusin', setFocusInRootElement); window.removeEventListener('focusin', setFocusInRootElement);
window.removeEventListener('blur', addFocusinListener); window.removeEventListener('focusout', addFocusinListener);
rootElement.removeChild(tabDetectionElement); rootElement.removeChild(tabDetectionElement);
rootElement.style.removeProperty('outline'); rootElement.style.removeProperty('outline');
} }
window.addEventListener('keydown', handleKeydown); window.addEventListener('keydown', handleKeydown);
window.addEventListener('blur', addFocusinListener); window.addEventListener('focusout', addFocusinListener);
createHelpersDetectingTabDirection(); createHelpersDetectingTabDirection();
return { disconnect }; return { disconnect };

View file

@ -358,7 +358,7 @@ describe('OverlayController', () => {
const ctrl = new OverlayController({ const ctrl = new OverlayController({
...withGlobalTestConfig(), ...withGlobalTestConfig(),
contentNode, contentNode,
trapsKeyboardFocus: true, trapsKeyboardFocus: false,
}); });
// add element to dom to allow focus // add element to dom to allow focus
/** @type {HTMLElement} */ (await fixture(html`${ctrl.content}`)); /** @type {HTMLElement} */ (await fixture(html`${ctrl.content}`));