blob: 9a0777e389bd0272ac13c687f389d62bb53a4dfc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import select from 'select-dom';
import features from '../libs/features';
function init(): void {
document.body.addEventListener('toggle', event => {
const confirmButton = select<HTMLButtonElement>('[open] details-dialog [type="submit"]', event.target as HTMLElement);
if (confirmButton) {
setTimeout(() => {
confirmButton.focus();
document.body.classList.remove('intent-mouse'); // Without this, the :focus style isn't applied
});
}
}, true); // The `toggle` event doesn't bubble, so it needs to be captured
}
features.add({
id: __featureName__,
description: 'Always focuses confirm buttons in custom modal boxes, like "Mark all as read".',
screenshot: 'https://user-images.githubusercontent.com/1402241/31700158-1499bdd8-b38d-11e7-9aba-77a0a4b6bf3c.png',
init
});
|