From eb11701e8f174e9c28d9f0dd1321de77cb44f82a Mon Sep 17 00:00:00 2001 From: Alexey Sudilovskiy Date: Fri, 22 Dec 2023 15:23:34 +0100 Subject: [PATCH 1/4] fix(Table): check that data exist --- src/components/Table/Table.tsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx index 0eb6b2d695..f5cc18c22d 100644 --- a/src/components/Table/Table.tsx +++ b/src/components/Table/Table.tsx @@ -346,9 +346,15 @@ export class Table> extends Rea return ( - {columnsStyles.map(({width}, index) => ( - - ))} + {columnsStyles.flatMap(({width}, index) => { + const key = columns[index]?.id; + + if (!key) { + return []; + } + + return ; + })} ); } @@ -553,10 +559,11 @@ export class Table> extends Rea return style; } - private getCellStyles({ - width: _width, - ...styles - }: React.CSSProperties): React.CSSProperties | undefined { + private getCellStyles( + columnStyles: React.CSSProperties | undefined, + ): React.CSSProperties | undefined { + const {width: _width, ...styles} = columnStyles || {}; + return Object.keys(styles).length ? styles : undefined; } From e3a26b7f73dd85d3e03e6d9d676d43806b0452e0 Mon Sep 17 00:00:00 2001 From: Alexey Sudilovskiy Date: Fri, 22 Dec 2023 15:50:47 +0100 Subject: [PATCH 2/4] feat: improve settings button a11y --- src/components/Table/hoc/withTableSettings/i18n/en.json | 3 +++ src/components/Table/hoc/withTableSettings/i18n/index.ts | 8 ++++++++ src/components/Table/hoc/withTableSettings/i18n/ru.json | 3 +++ .../Table/hoc/withTableSettings/withTableSettings.tsx | 2 ++ 4 files changed, 16 insertions(+) create mode 100644 src/components/Table/hoc/withTableSettings/i18n/en.json create mode 100644 src/components/Table/hoc/withTableSettings/i18n/index.ts create mode 100644 src/components/Table/hoc/withTableSettings/i18n/ru.json diff --git a/src/components/Table/hoc/withTableSettings/i18n/en.json b/src/components/Table/hoc/withTableSettings/i18n/en.json new file mode 100644 index 0000000000..6c6be2b142 --- /dev/null +++ b/src/components/Table/hoc/withTableSettings/i18n/en.json @@ -0,0 +1,3 @@ +{ + "label_settings": "Table settings" +} diff --git a/src/components/Table/hoc/withTableSettings/i18n/index.ts b/src/components/Table/hoc/withTableSettings/i18n/index.ts new file mode 100644 index 0000000000..c9cd67b71b --- /dev/null +++ b/src/components/Table/hoc/withTableSettings/i18n/index.ts @@ -0,0 +1,8 @@ +import {addComponentKeysets} from '../../../../utils/addComponentKeysets'; + +import en from './en.json'; +import ru from './ru.json'; + +const COMPONENT = 'withTableSettings'; + +export default addComponentKeysets({en, ru}, COMPONENT); diff --git a/src/components/Table/hoc/withTableSettings/i18n/ru.json b/src/components/Table/hoc/withTableSettings/i18n/ru.json new file mode 100644 index 0000000000..0b7ef79d59 --- /dev/null +++ b/src/components/Table/hoc/withTableSettings/i18n/ru.json @@ -0,0 +1,3 @@ +{ + "label_settings": "Настройки таблицы" +} diff --git a/src/components/Table/hoc/withTableSettings/withTableSettings.tsx b/src/components/Table/hoc/withTableSettings/withTableSettings.tsx index 4b7e0761e8..634b87a66c 100644 --- a/src/components/Table/hoc/withTableSettings/withTableSettings.tsx +++ b/src/components/Table/hoc/withTableSettings/withTableSettings.tsx @@ -14,6 +14,7 @@ import {actionsColumnId, enhanceSystemColumn} from '../withTableActions/withTabl import {selectionColumnId} from '../withTableSelection/withTableSelection'; import {TableColumnSetup} from './TableColumnSetup/TableColumnSetup'; +import i18n from './i18n'; import './withTableSettings.scss'; @@ -191,6 +192,7 @@ export function withTableSettings(