move tabindex setting to modal controls

This commit is contained in:
2026-05-14 08:45:31 -07:00
parent c4b7faca88
commit 4f0a0f3969
2 changed files with 3 additions and 1 deletions

View File

@ -36,7 +36,7 @@ layout: base.njk
<button class="close-dialog" autofocus aria-label="close the image modal">&times;</button>
<img class="modal-img" src="/img/{{ image.src }}" alt="{{ image.alt }}">
</dialog>
<img tabindex="0" class="hero" src="/img/{{ image.src }}" alt="{{ image.alt }}">
<img class="hero" src="/img/{{ image.src }}" alt="{{ image.alt }}">
{% endif %}
{{ content | safe }}

View File

@ -4,6 +4,8 @@ if (window.innerWidth > 650) {
const closeButton = document.querySelector(".close-dialog");
const hero = document.querySelector(".hero");
hero.tabIndex = 0;
hero.addEventListener("click", (e) => dialog.showModal());
hero.addEventListener("keydown", (e) => {
if (e.key === "Enter" || e.key === " ") {