Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aria-readonly to readonly cells #2379

Merged
merged 2 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -107,6 +107,7 @@ function Cell<R, SR>({
aria-colindex={column.idx + 1} // aria-colindex is 1-based
aria-selected={isCellSelected}
aria-colspan={colSpan}
aria-readonly={isCellEditable(column, row) ? true : undefined}
amanmahajan7 marked this conversation as resolved.
Show resolved Hide resolved
ref={ref}
className={className}
style={getCellStyle(column, colSpan)}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/selectedCellUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ interface IsSelectedCellEditableOpts<R, SR> {
export function isSelectedCellEditable<R, SR>({ selectedPosition, columns, rows, isGroupRow }: IsSelectedCellEditableOpts<R, SR>): boolean {
const column = columns[selectedPosition.idx];
const row = rows[selectedPosition.rowIdx];
return !isGroupRow(row) && isCellEditable(column, row);
}

export function isCellEditable<R, SR>(column: CalculatedColumn<R, SR>, row: R): boolean {
return column.editor != null
&& !column.rowGroup
&& !isGroupRow(row)
&& (typeof column.editable === 'function' ? column.editable(row) : column.editable) !== false;
}

Expand Down