feat: include search results in the spotlight tab order

This commit is contained in:
Philipinho
2026-08-24 23:47:03 +01:00
parent 271fcc070e
commit f7ae9e8e95
2 changed files with 21 additions and 0 deletions
@@ -26,6 +26,14 @@ interface SearchResultItemProps {
showSpace?: boolean; showSpace?: boolean;
} }
// Spotlight hardcodes tabIndex={-1} after spreading props; a ref wins and
// React never writes -1 back because the prop value never changes
const makeActionTabbable = (el: HTMLElement | null) => {
if (el) {
el.tabIndex = 0;
}
};
export function SearchResultItem({ export function SearchResultItem({
result, result,
isAttachmentResult, isAttachmentResult,
@@ -46,6 +54,7 @@ export function SearchResultItem({
return ( return (
<Spotlight.Action <Spotlight.Action
component={Link} component={Link}
ref={makeActionTabbable}
//@ts-ignore //@ts-ignore
to={buildPageUrl( to={buildPageUrl(
attachmentResult.space.slug, attachmentResult.space.slug,
@@ -96,6 +105,7 @@ export function SearchResultItem({
return ( return (
<Spotlight.Action <Spotlight.Action
component={Link} component={Link}
ref={makeActionTabbable}
//@ts-ignore //@ts-ignore
to={buildPageUrl( to={buildPageUrl(
pageResult.space.slug, pageResult.space.slug,
+11
View File
@@ -50,3 +50,14 @@
--action-description-color: var(--mantine-color-dimmed); --action-description-color: var(--mantine-color-dimmed);
--action-description-opacity: 1; --action-description-opacity: 1;
} }
/* Result actions are tab stops (tabIndex restored via ref); give keyboard
* focus the same gray treatment as arrow-key selection so both navigation
* modes read identically (WCAG 2.4.7 focus visible).
*/
.mantine-Spotlight-action:focus-visible {
background-color: light-dark(
var(--mantine-color-gray-1),
var(--mantine-color-dark-5)
);
}