diff --git a/_includes/components/fediverse-modal.njk b/_includes/components/fediverse-modal.njk index 6dd693b..0f95228 100644 --- a/_includes/components/fediverse-modal.njk +++ b/_includes/components/fediverse-modal.njk @@ -5,14 +5,7 @@
!el.closest('[x-show]') || el.closest('[x-show]').style.display !== 'none'); - if (!focusable.length) return; - const first = focusable[0]; - const last = focusable[focusable.length - 1]; - if ($event.shiftKey && document.activeElement === first) { $event.preventDefault(); last.focus(); } - else if (!$event.shiftKey && document.activeElement === last) { $event.preventDefault(); first.focus(); } - "> + @keydown.tab="trapFocus($event)"> {# Backdrop #}
{ } }, + trapFocus(event) { + const focusable = [...this.$el.querySelectorAll('button, input, a, [tabindex]:not([tabindex="-1"])')].filter(el => !el.closest('[x-show]') || el.closest('[x-show]').style.display !== 'none'); + if (!focusable.length) return; + const first = focusable[0]; + const last = focusable[focusable.length - 1]; + if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); } + else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); } + }, + redirectToInstance(domain) { if (this.mode === "share") { window.location.href = `https://${domain}/share?text=${encodeURIComponent(this.targetUrl)}`;