Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(website): address automated review accessibility findings
Elian Doran1496e50d9ee9
diff --git a/apps/website/src/components/LanguageSelector.tsx b/apps/website/src/components/LanguageSelector.tsxindex 81a3eb68f1..e527ae1462 100644--- a/apps/website/src/components/LanguageSelector.tsx+++ b/apps/website/src/components/LanguageSelector.tsx@@ -55,12 +55,13 @@ export default function LanguageSelector({ className, inline, onSelect }: Langua<Icon svg={globeIcon} className="globe" />{t("header.language")}</span>- <ul className="language-menu" role="listbox">+ <ul className="language-menu">{LOCALES.map(locale => (- <li key={locale.id} role="option" aria-selected={locale.id === currentLocale}>+ <li key={locale.id}><Linkhref={swapLocaleInUrl(url, locale.id)}className={locale.id === currentLocale ? "active" : ""}+ aria-current={locale.id === currentLocale ? "page" : undefined}onClick={onSelect}>{locale.name}@@ -77,7 +78,7 @@ export default function LanguageSelector({ className, inline, onSelect }: Langua<buttontype="button"className="language-toggle"- aria-haspopup="listbox"+ aria-haspopup="true"aria-expanded={open}onClick={() => setOpen(!open)}>@@ -87,12 +88,13 @@ export default function LanguageSelector({ className, inline, onSelect }: Langua</button>{open && (- <ul className="language-menu" role="listbox">+ <ul className="language-menu">{LOCALES.map(locale => (- <li key={locale.id} role="option" aria-selected={locale.id === currentLocale}>+ <li key={locale.id}><Linkhref={swapLocaleInUrl(url, locale.id)}className={locale.id === currentLocale ? "active" : ""}+ aria-current={locale.id === currentLocale ? "page" : undefined}onClick={() => setOpen(false)}>{locale.name}diff --git a/apps/website/src/components/SectionNav.tsx b/apps/website/src/components/SectionNav.tsxindex f6a5a3fbe9..d04bfcea8d 100644--- a/apps/website/src/components/SectionNav.tsx+++ b/apps/website/src/components/SectionNav.tsx@@ -46,8 +46,14 @@ export default function SectionNav({ items }: { items: SectionNavItem[] }) {}function useActiveSection(items: SectionNavItem[], setActiveId: (id: string) => void) {+ // Hold the latest items in a ref so the observer reads current values without+ // being torn down and rebuilt whenever the parent passes a fresh array literal.+ const itemsRef = useRef(items);+ itemsRef.current = items;+ const itemIds = items.map((item) => item.id).join(",");+useEffect(() => {- const sections = items+ const sections = itemsRef.current.map((item) => document.getElementById(item.id)).filter((el): el is HTMLElement => el !== null);if (sections.length === 0) {@@ -65,7 +71,7 @@ function useActiveSection(items: SectionNavItem[], setActiveId: (id: string) =>}}// The topmost section that has crossed the trigger line wins.- const current = items.find((item) => visible.has(item.id));+ const current = itemsRef.current.find((item) => visible.has(item.id));if (current) {setActiveId(current.id);}@@ -77,5 +83,5 @@ function useActiveSection(items: SectionNavItem[], setActiveId: (id: string) =>sections.forEach((section) => observer.observe(section));return () => observer.disconnect();- }, [ items, setActiveId ]);+ }, [ itemIds, setActiveId ]);}diff --git a/apps/website/src/pages/Home/index.tsx b/apps/website/src/pages/Home/index.tsxindex 1c4cc97e1d..47fef3f796 100644--- a/apps/website/src/pages/Home/index.tsx+++ b/apps/website/src/pages/Home/index.tsx@@ -362,12 +362,12 @@ function ImportSection() {<div className="import-logos"><span className="import-logos-label">{t("import.sources_label")}</span><div className="import-logos-row">- <span className="import-logo" title={t("import.onenote_title")}><Icon svg={oneNoteIcon} /></span>- <span className="import-logo" title={t("import.notion_title")}><Icon svg={notionIcon} /></span>- <span className="import-logo" title={t("import.keep_title")}><Icon svg={keepIcon} /></span>- <span className="import-logo" title={t("import.evernote_title")}><Icon svg={evernoteIcon} /></span>- <span className="import-logo" title={t("import.anytype_title")}><Icon svg={anytypeIcon} /></span>- <span className="import-logo" title={t("import.obsidian_title")}><Icon svg={obsidianIcon} /></span>+ <span className="import-logo" role="img" aria-label={t("import.onenote_title")} title={t("import.onenote_title")}><Icon svg={oneNoteIcon} /></span>+ <span className="import-logo" role="img" aria-label={t("import.notion_title")} title={t("import.notion_title")}><Icon svg={notionIcon} /></span>+ <span className="import-logo" role="img" aria-label={t("import.keep_title")} title={t("import.keep_title")}><Icon svg={keepIcon} /></span>+ <span className="import-logo" role="img" aria-label={t("import.evernote_title")} title={t("import.evernote_title")}><Icon svg={evernoteIcon} /></span>+ <span className="import-logo" role="img" aria-label={t("import.anytype_title")} title={t("import.anytype_title")}><Icon svg={anytypeIcon} /></span>+ <span className="import-logo" role="img" aria-label={t("import.obsidian_title")} title={t("import.obsidian_title")}><Icon svg={obsidianIcon} /></span></div></div></Card>@@ -414,10 +414,11 @@ function TabbedShowcase({ items }: { items: ShowcaseItem[] }) {<buttontype="button"role="tab"+ id={`showcase-tab-${index}`}aria-selected={isActive}+ aria-controls={`showcase-panel-${index}`}className={`showcase-tab ${isActive ? "active" : ""}`}onClick={() => setActiveIndex(index)}- onMouseEnter={() => setActiveIndex(index)}onFocus={() => setActiveIndex(index)}>{item.iconSvg && <span className="tab-icon"><Icon svg={item.iconSvg} /></span>}@@ -428,7 +429,7 @@ function TabbedShowcase({ items }: { items: ShowcaseItem[] }) {})}</ul>- <div className="showcase-preview" key={activeIndex} role="tabpanel">+ <div className="showcase-preview" key={activeIndex} role="tabpanel" id={`showcase-panel-${activeIndex}`} aria-labelledby={`showcase-tab-${activeIndex}`}><div className="showcase-image-frame"><img src={active.imageUrl} alt={active.title} loading="lazy" /></div>