From 8c4b9d27f242a89cde09550b81c41362adf9142a Mon Sep 17 00:00:00 2001 From: andrzej Date: Sun, 30 Jun 2024 20:28:02 +0200 Subject: [PATCH] improve tab nav --- src/app/publication/columns.tsx | 2 ++ src/app/ui/inputs/textInput.tsx | 7 ++++++- src/app/ui/tables/contextMenu.tsx | 16 ++-------------- src/app/ui/tables/selectColumn.tsx | 4 +++- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/app/publication/columns.tsx b/src/app/publication/columns.tsx index 44637d4..419f423 100644 --- a/src/app/publication/columns.tsx +++ b/src/app/publication/columns.tsx @@ -18,11 +18,13 @@ import { PubsWithGenres } from "./page" import { DialogClose } from "@radix-ui/react-dialog" import { actions } from "app/ui/tables/actions" import { TextInputCell } from "app/ui/inputs/textInput" +import { selectCol } from "app/ui/tables/selectColumn" const columnHelper = createColumnHelper() export const columns: ColumnDef[] = [ + selectCol, { accessorKey: "title", header: ({ column }) => { diff --git a/src/app/ui/inputs/textInput.tsx b/src/app/ui/inputs/textInput.tsx index f5e126b..9382c7e 100644 --- a/src/app/ui/inputs/textInput.tsx +++ b/src/app/ui/inputs/textInput.tsx @@ -27,7 +27,6 @@ export const TextInputCell = (props: CellContext) => { handleClose() } function handleOpen() { - console.log(props.row.getEx) setIsActive(true) } function handleClose() { @@ -44,6 +43,12 @@ export const TextInputCell = (props: CellContext) => { return (
setIsActive(prev => !prev)} className="w-full h-fit flex items-center justify-center" + tabIndex={0} + onKeyDown={e => { + if (e.code === "Enter" && !isActive) { + setIsActive(true) + } + }} > {isActive ? & : "" } + { - selectedRows.length <= 1 ? - - Edit - - {Object.keys(row.original).map(e => { - if (e !== "id") { - return {letterCase(e)} - } - })} - - : "" - } - { - selectedRows ? + selectedRows.length > 0 ? { table.resetRowSelection() }}>Deselect : "" } diff --git a/src/app/ui/tables/selectColumn.tsx b/src/app/ui/tables/selectColumn.tsx index 622bdf2..8432b35 100644 --- a/src/app/ui/tables/selectColumn.tsx +++ b/src/app/ui/tables/selectColumn.tsx @@ -22,7 +22,9 @@ export const selectCol = { + aria-label="select/deselect row" + /> +
) }