From 603117775d3135bb36511e921b53edf809fa8207 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 2 Dec 2025 14:00:22 +0200 Subject: [PATCH 01/12] [BasicTable] unify handling of `tableCaptions` whether or not the user specifies them --- .../components/basic_table/basic_table.tsx | 59 +++++++++---------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 7439747624b..40f8b2993e6 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -327,7 +327,7 @@ export class EuiBasicTable extends Component< prevState: State ) { if (!nextProps.selection) { - // next props doesn't have a selection, reset our state + // next props don't have a selection, reset our state return { selection: [] }; } @@ -631,48 +631,43 @@ export class EuiBasicTable extends Component< ? Math.ceil(pagination.totalItemCount / this.pageSize) : 1; - let captionElement; - if (tableCaption) { - if (pagination) { + const baseName = tableCaption || ( + + ); + + let captionElement: React.ReactNode; + + if (pagination) { + if (totalItemCount > 0) { captionElement = ( ); - } else { - captionElement = tableCaption; - } - } else { - if (pagination) { - if (pagination.totalItemCount > 0) { - captionElement = ( - - ); - } else { - captionElement = ( - - ); - } } else { captionElement = ( ); } + } else { + captionElement = ( + + ); } + return ( From 149a74a5698cb5e85b14c52e050f453eebc3acbc Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 2 Dec 2025 14:17:01 +0200 Subject: [PATCH 02/12] changelog --- packages/eui/changelogs/upcoming/9254.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/eui/changelogs/upcoming/9254.md diff --git a/packages/eui/changelogs/upcoming/9254.md b/packages/eui/changelogs/upcoming/9254.md new file mode 100644 index 00000000000..e65db5d7a03 --- /dev/null +++ b/packages/eui/changelogs/upcoming/9254.md @@ -0,0 +1,3 @@ +**Accessibility** + +- Improved `EuiBasicTable` accessibility by unifying the handling of `tableCaptions` whether the user provides the parameter. From 8e672dc758546a9b13cee8ea30415a6172483ec6 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 2 Dec 2025 20:11:24 +0200 Subject: [PATCH 03/12] update comment --- packages/eui/src/components/basic_table/basic_table.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 40f8b2993e6..dcef13d2749 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -235,7 +235,7 @@ interface BasicTableProps */ error?: string; /** - * Describes the content of the table. If not specified, the caption will be "This table contains {itemCount} rows." + * Provides a description of the table’s content. If no description is provided, the table will default to the name Data Table. */ tableCaption?: string; /** From 880959aa9722a8a321b268550b7587ce5a424adc Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 2 Dec 2025 22:22:48 +0200 Subject: [PATCH 04/12] cleanup --- .../components/basic_table/basic_table.tsx | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index dcef13d2749..16275ce9080 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -631,48 +631,55 @@ export class EuiBasicTable extends Component< ? Math.ceil(pagination.totalItemCount / this.pageSize) : 1; - const baseName = tableCaption || ( - + const tableName = tableCaption || ( + ); - let captionElement: React.ReactNode; - - if (pagination) { - if (totalItemCount > 0) { - captionElement = ( - - ); - } else { - captionElement = ( + const itemCountPart = (() => { + if (!itemCount) { + return this.props.noItemsMessage; + } else if (totalItemCount > 0) { + return ( ); } - } else { - captionElement = ( + return ( ); - } + })(); + + const paginationPart = (() => { + if (pagination && page && pageCount) { + return ( + + ); + } + return ''; + })(); return ( {tabularCopyMarkers.hiddenNoCopyBoundary} - {captionElement} + + + {tabularCopyMarkers.hiddenNoCopyBoundary} From 974e3b67c588228b58defee048e13d1a1890d7d7 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Wed, 3 Dec 2025 13:05:14 +0200 Subject: [PATCH 05/12] cleanup --- .../eui/src/components/basic_table/basic_table.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 16275ce9080..870ef9d9397 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -642,18 +642,12 @@ export class EuiBasicTable extends Component< return ( ); } - return ( - - ); + return ''; })(); const paginationPart = (() => { From b4bae814ad0837f3f1ad9cfcbd1a1532ed936098 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Wed, 3 Dec 2025 13:09:12 +0200 Subject: [PATCH 06/12] cleanup --- .../components/basic_table/basic_table.tsx | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 870ef9d9397..1b1faed868b 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -635,33 +635,29 @@ export class EuiBasicTable extends Component< ); - const itemCountPart = (() => { - if (!itemCount) { - return this.props.noItemsMessage; - } else if (totalItemCount > 0) { - return ( - - ); - } - return ''; - })(); - - const paginationPart = (() => { - if (pagination && page && pageCount) { - return ( - - ); - } - return ''; - })(); + let itemCountPart: React.ReactNode = ''; + if (!itemCount) { + itemCountPart = this.props.noItemsMessage; + } else if (totalItemCount > 0) { + itemCountPart = ( + + ); + } + + let paginationPart: React.ReactNode = ''; + if (pagination && page && pageCount) { + paginationPart = ( + + ); + } return ( From 58ec23b4a9d56c9142da53d8a57be9a173b2acc6 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Wed, 3 Dec 2025 13:14:04 +0200 Subject: [PATCH 07/12] cleanup --- packages/eui/src/components/basic_table/basic_table.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 1b1faed868b..05d3730a77a 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -649,7 +649,7 @@ export class EuiBasicTable extends Component< } let paginationPart: React.ReactNode = ''; - if (pagination && page && pageCount) { + if (pagination && pageCount > 1) { paginationPart = ( Date: Wed, 3 Dec 2025 14:52:30 +0200 Subject: [PATCH 08/12] cleanup --- .../eui/src/components/basic_table/basic_table.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 05d3730a77a..394d463f2af 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -635,7 +635,7 @@ export class EuiBasicTable extends Component< ); - let itemCountPart: React.ReactNode = ''; + let itemCountPart: React.ReactNode = null; if (!itemCount) { itemCountPart = this.props.noItemsMessage; } else if (totalItemCount > 0) { @@ -648,7 +648,7 @@ export class EuiBasicTable extends Component< ); } - let paginationPart: React.ReactNode = ''; + let paginationPart: React.ReactNode = null; if (pagination && pageCount > 1) { paginationPart = ( extends Component< {tabularCopyMarkers.hiddenNoCopyBoundary} - + {tableName} + {itemCountPart} + {paginationPart} {tabularCopyMarkers.hiddenNoCopyBoundary} From 07522a48a795d66dd64bdb3d175c4b77c261a055 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Wed, 3 Dec 2025 16:00:33 +0200 Subject: [PATCH 09/12] cleanup --- packages/eui/src/components/basic_table/basic_table.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 394d463f2af..46a308f5bf5 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -638,7 +638,7 @@ export class EuiBasicTable extends Component< let itemCountPart: React.ReactNode = null; if (!itemCount) { itemCountPart = this.props.noItemsMessage; - } else if (totalItemCount > 0) { + } else if (pagination && totalItemCount > 0) { itemCountPart = ( Date: Wed, 3 Dec 2025 17:28:12 +0200 Subject: [PATCH 10/12] cleanup --- .../components/basic_table/basic_table.tsx | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 46a308f5bf5..08e51fc051d 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -631,31 +631,31 @@ export class EuiBasicTable extends Component< ? Math.ceil(pagination.totalItemCount / this.pageSize) : 1; - const tableName = tableCaption || ( - - ); - let itemCountPart: React.ReactNode = null; if (!itemCount) { itemCountPart = this.props.noItemsMessage; } else if (pagination && totalItemCount > 0) { itemCountPart = ( - +

+ +

); } let paginationPart: React.ReactNode = null; if (pagination && pageCount > 1) { paginationPart = ( - +

+ +

); } @@ -664,7 +664,14 @@ export class EuiBasicTable extends Component< {tabularCopyMarkers.hiddenNoCopyBoundary} - {tableName} +

+ {tableCaption || ( + + )} +

{itemCountPart} {paginationPart}
From c2f81d5632191c1ea8700d9e648d53160c70529d Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 8 Dec 2025 14:08:27 +0200 Subject: [PATCH 11/12] Update packages/eui/changelogs/upcoming/9254.md Co-authored-by: Lene Gadewoll --- packages/eui/changelogs/upcoming/9254.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eui/changelogs/upcoming/9254.md b/packages/eui/changelogs/upcoming/9254.md index e65db5d7a03..fcdd7b2d237 100644 --- a/packages/eui/changelogs/upcoming/9254.md +++ b/packages/eui/changelogs/upcoming/9254.md @@ -1,3 +1,3 @@ **Accessibility** -- Improved `EuiBasicTable` accessibility by unifying the handling of `tableCaptions` whether the user provides the parameter. +- Improved `EuiBasicTable` accessibility by ensuring a fallback `tableCaption` is applied if none is provided From 58385c266bf483b9c996b5b4c9e23fbef44866c2 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 8 Dec 2025 14:13:10 +0200 Subject: [PATCH 12/12] Update basic_table.tsx --- packages/eui/src/components/basic_table/basic_table.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eui/src/components/basic_table/basic_table.tsx b/packages/eui/src/components/basic_table/basic_table.tsx index 08e51fc051d..0c0b469aa41 100644 --- a/packages/eui/src/components/basic_table/basic_table.tsx +++ b/packages/eui/src/components/basic_table/basic_table.tsx @@ -639,7 +639,7 @@ export class EuiBasicTable extends Component<