I have a fly-out menu on my website, that closes when the user clicks away (anywhere else on the page) using an event listener. I would like to do the same but for accessible user for when they tab away from the fly-out menu. Any help doing this would be appreciated.
configure() {
window.addEventListener('resize', debounce(this.resize.bind(this), 300));
window.addEventListener('blur', () => once(window, 'focus', this.resize.bind(this)));
this.more_btn.addEventListener('click', () => {
if (this.more_list.classList.contains('hidden')) {
setTimeout(() => {
once(window, 'click', () => {
this.container.classList.remove('opened');
this.more_list.classList.add('hidden');
toggleAria(this.more_list, 'aria-expanded');
});
}, 100);
}
this.container.classList.toggle('opened');
this.more_list.classList.toggle('hidden');
toggleAria(this.more_list, 'aria-expanded');
});
this.dropdown.addEventListener('click', () => {
this.toggle();
});
this.resize();
}