style: format segment editor
This commit is contained in:
@@ -57,7 +57,8 @@ export const setupSegmentEditor = (): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const open = (): void => {
|
const open = (): void => {
|
||||||
lastActiveElement = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
lastActiveElement =
|
||||||
|
document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||||
panel.classList.remove('hidden');
|
panel.classList.remove('hidden');
|
||||||
panel.classList.add('flex');
|
panel.classList.add('flex');
|
||||||
panel.setAttribute('aria-hidden', 'false');
|
panel.setAttribute('aria-hidden', 'false');
|
||||||
@@ -89,8 +90,10 @@ export const setupSegmentEditor = (): void => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.key !== 'Tab') return;
|
if (e.key !== 'Tab') return;
|
||||||
const focusables = Array.from(panel.querySelectorAll(focusableSelector))
|
const focusables = Array.from(panel.querySelectorAll(focusableSelector)).filter(
|
||||||
.filter(el => el instanceof HTMLElement && !el.hasAttribute('disabled') && !el.getAttribute('aria-hidden')) as HTMLElement[];
|
el =>
|
||||||
|
el instanceof HTMLElement && !el.hasAttribute('disabled') && !el.getAttribute('aria-hidden')
|
||||||
|
) as HTMLElement[];
|
||||||
if (focusables.length === 0) return;
|
if (focusables.length === 0) return;
|
||||||
|
|
||||||
const first = focusables[0];
|
const first = focusables[0];
|
||||||
@@ -115,7 +118,10 @@ export const setupSegmentEditor = (): void => {
|
|||||||
if (panel.classList.contains('hidden')) return;
|
if (panel.classList.contains('hidden')) return;
|
||||||
const target = e.target as Node | null;
|
const target = e.target as Node | null;
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
if ((e.target as HTMLElement | null)?.closest('[data-segment-editor] [data-segment-editor-close]')) return;
|
if (
|
||||||
|
(e.target as HTMLElement | null)?.closest('[data-segment-editor] [data-segment-editor-close]')
|
||||||
|
)
|
||||||
|
return;
|
||||||
const content = panel.firstElementChild;
|
const content = panel.firstElementChild;
|
||||||
if (content && content.contains(target)) return;
|
if (content && content.contains(target)) return;
|
||||||
close();
|
close();
|
||||||
|
|||||||
Reference in New Issue
Block a user