mirror of
https://github.com/docmost/docmost.git
synced 2026-07-26 10:04:46 +10:00
feat(base): make column headers keyboard-focusable as tab stops
This commit is contained in:
@@ -60,6 +60,7 @@ export const GridHeaderCell = memo(function GridHeaderCell({
|
|||||||
const { selectionCount } = useRowSelection(pageId);
|
const { selectionCount } = useRowSelection(pageId);
|
||||||
const hasSelection = selectionCount > 0;
|
const hasSelection = selectionCount > 0;
|
||||||
const editable = useBaseEditable();
|
const editable = useBaseEditable();
|
||||||
|
const isHeaderInteractive = editable && !!property && !isRowNumber;
|
||||||
|
|
||||||
const [activePropertyMenu, setActivePropertyMenu] = useAtom(activePropertyMenuAtomFamily(pageId)) as unknown as [string | null, (val: string | null) => void];
|
const [activePropertyMenu, setActivePropertyMenu] = useAtom(activePropertyMenuAtomFamily(pageId)) as unknown as [string | null, (val: string | null) => void];
|
||||||
const menuOpened = activePropertyMenu === header.column.id;
|
const menuOpened = activePropertyMenu === header.column.id;
|
||||||
@@ -208,6 +209,9 @@ export const GridHeaderCell = memo(function GridHeaderCell({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={cellRef}
|
ref={cellRef}
|
||||||
|
role={isRowNumber ? undefined : "columnheader"}
|
||||||
|
tabIndex={isHeaderInteractive ? 0 : undefined}
|
||||||
|
aria-haspopup={isHeaderInteractive ? "menu" : undefined}
|
||||||
className={`${classes.headerCell} ${isPinned ? classes.headerCellPinned : ""} ${hasSelection ? classes.hasSelection : ""}`}
|
className={`${classes.headerCell} ${isPinned ? classes.headerCellPinned : ""} ${hasSelection ? classes.hasSelection : ""}`}
|
||||||
style={{
|
style={{
|
||||||
...(isPinned
|
...(isPinned
|
||||||
@@ -220,6 +224,12 @@ export const GridHeaderCell = memo(function GridHeaderCell({
|
|||||||
resizeIntentRef.current = false;
|
resizeIntentRef.current = false;
|
||||||
}}
|
}}
|
||||||
onClick={handleHeaderClick}
|
onClick={handleHeaderClick}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
|
e.preventDefault();
|
||||||
|
handleHeaderClick();
|
||||||
|
}
|
||||||
|
}}
|
||||||
data-dragging={isDragging || undefined}
|
data-dragging={isDragging || undefined}
|
||||||
>
|
>
|
||||||
{isRowNumber ? (
|
{isRowNumber ? (
|
||||||
@@ -269,6 +279,7 @@ export const GridHeaderCell = memo(function GridHeaderCell({
|
|||||||
shadow="md"
|
shadow="md"
|
||||||
width={260}
|
width={260}
|
||||||
trapFocus
|
trapFocus
|
||||||
|
returnFocus
|
||||||
withinPortal
|
withinPortal
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
|
|||||||
@@ -242,6 +242,12 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.headerCell:focus-visible {
|
||||||
|
outline: 2px solid var(--mantine-color-blue-5);
|
||||||
|
outline-offset: -2px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.cellContent {
|
.cellContent {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user