From 88892859925d848306667c6bc1bfbdb5c88b7b97 Mon Sep 17 00:00:00 2001 From: Aman Mahajan Date: Tue, 27 Apr 2021 07:49:02 -0500 Subject: [PATCH 1/2] Add aria-readonly --- src/Cell.tsx | 3 ++- src/utils/selectedCellUtils.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Cell.tsx b/src/Cell.tsx index 6b8b2fc4eb..e8b2fd24c8 100644 --- a/src/Cell.tsx +++ b/src/Cell.tsx @@ -3,7 +3,7 @@ import type { RefAttributes } from 'react'; import { css } from '@linaria/core'; import { cellSelectedClassname } from './style'; -import { getCellStyle, getCellClassname } from './utils'; +import { getCellStyle, getCellClassname, isCellEditable } from './utils'; import type { CellRendererProps } from './types'; const cellCopied = css` @@ -107,6 +107,7 @@ function Cell({ aria-colindex={column.idx + 1} // aria-colindex is 1-based aria-selected={isCellSelected} aria-colspan={colSpan} + aria-readonly={isCellEditable(column, row) ? true : undefined} ref={ref} className={className} style={getCellStyle(column, colSpan)} diff --git a/src/utils/selectedCellUtils.ts b/src/utils/selectedCellUtils.ts index 4b92d670df..63b4cc8c99 100644 --- a/src/utils/selectedCellUtils.ts +++ b/src/utils/selectedCellUtils.ts @@ -11,9 +11,12 @@ interface IsSelectedCellEditableOpts { export function isSelectedCellEditable({ selectedPosition, columns, rows, isGroupRow }: IsSelectedCellEditableOpts): boolean { const column = columns[selectedPosition.idx]; const row = rows[selectedPosition.rowIdx]; + return !isGroupRow(row) && isCellEditable(column, row); +} + +export function isCellEditable(column: CalculatedColumn, row: R): boolean { return column.editor != null && !column.rowGroup - && !isGroupRow(row) && (typeof column.editable === 'function' ? column.editable(row) : column.editable) !== false; } From d8fcee25ebdfea9681fadb1f8edd22c568236a29 Mon Sep 17 00:00:00 2001 From: Aman Mahajan Date: Tue, 27 Apr 2021 08:36:38 -0500 Subject: [PATCH 2/2] Update src/Cell.tsx Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> --- src/Cell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cell.tsx b/src/Cell.tsx index e8b2fd24c8..48df2a3e67 100644 --- a/src/Cell.tsx +++ b/src/Cell.tsx @@ -107,7 +107,7 @@ function Cell({ aria-colindex={column.idx + 1} // aria-colindex is 1-based aria-selected={isCellSelected} aria-colspan={colSpan} - aria-readonly={isCellEditable(column, row) ? true : undefined} + aria-readonly={isCellEditable(column, row) || undefined} ref={ref} className={className} style={getCellStyle(column, colSpan)}