feat(ux): Add proper ARIA attributes to Lightbox modal and EXIF toggle (#45)
Adds `role="dialog"`, `aria-modal="true"`, and `aria-label` to the `.overlay` container to improve screen reader accessibility. Also adds `aria-expanded` and `aria-controls` to the EXIF info toggle button, linking it to the newly ID'd `#exif-panel`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
## 2024-03-XX - Lightbox Accessibility
|
## 2024-05-24 - Lightbox ARIA Attributes
|
||||||
|
**Learning:** Adding `role="dialog"`, `aria-modal="true"`, and `aria-label` to custom modal/lightbox overlays ensures screen readers announce them properly instead of just falling back to reading inner content without context. Additionally, toggles that show/hide panels (like the EXIF info button) must use `aria-expanded` and link to the panel via `aria-controls` for proper screen reader communication.
|
||||||
**Learning:** Found that Lightbox overlay has good keyboard navigation (esc/left/right) but lacked tooltip hints for those controls and lacked a shortcut for EXIF data toggle.
|
**Action:** When building or modifying custom overlays or toggle buttons in the future, always verify that ARIA attributes are set correctly to match the visual behavior.
|
||||||
**Action:** Added `i` shortcut and `title` attributes on interactive elements in Lightbox.
|
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ export function Lightbox({ assets, currentIndex, onClose, onNext, onPrev }: Ligh
|
|||||||
onClick={handleOverlayClick}
|
onClick={handleOverlayClick}
|
||||||
onTouchStart={handleTouchStart}
|
onTouchStart={handleTouchStart}
|
||||||
onTouchEnd={handleTouchEnd}
|
onTouchEnd={handleTouchEnd}
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label="Image viewer"
|
||||||
>
|
>
|
||||||
{/* Close button */}
|
{/* Close button */}
|
||||||
<button className={styles.close} onClick={onClose} aria-label="Close" title="Close (Esc)">
|
<button className={styles.close} onClick={onClose} aria-label="Close" title="Close (Esc)">
|
||||||
@@ -188,6 +191,8 @@ export function Lightbox({ assets, currentIndex, onClose, onNext, onPrev }: Ligh
|
|||||||
<button
|
<button
|
||||||
className={styles.infoToggle}
|
className={styles.infoToggle}
|
||||||
onClick={handleExifToggle}
|
onClick={handleExifToggle}
|
||||||
|
aria-expanded={showExif}
|
||||||
|
aria-controls="exif-panel"
|
||||||
aria-label="Toggle photo info"
|
aria-label="Toggle photo info"
|
||||||
title="Toggle photo info (i)"
|
title="Toggle photo info (i)"
|
||||||
>
|
>
|
||||||
@@ -196,7 +201,7 @@ export function Lightbox({ assets, currentIndex, onClose, onNext, onPrev }: Ligh
|
|||||||
|
|
||||||
{/* EXIF panel */}
|
{/* EXIF panel */}
|
||||||
{showExif && (
|
{showExif && (
|
||||||
<div className={styles.exifPanel}>
|
<div id="exif-panel" className={styles.exifPanel}>
|
||||||
{exifLoading ? (
|
{exifLoading ? (
|
||||||
<div className={styles.exifRow}>
|
<div className={styles.exifRow}>
|
||||||
<span className={styles.exifLabel}>Loading...</span>
|
<span className={styles.exifLabel}>Loading...</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user