mirror of
https://github.com/docmost/docmost.git
synced 2026-08-25 15:57:11 +08:00
feat: include search results in the spotlight tab order
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user