From 2d154b422c494ffd5c9809d892352734a544f7ea Mon Sep 17 00:00:00 2001 From: Ilza Medeiros Date: Wed, 30 Oct 2024 15:40:14 -0300 Subject: [PATCH 1/2] fix(@clayui/core): LPD-39956 - Not render left arrow button when child array is empty --- packages/clay-core/src/table/Body.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/clay-core/src/table/Body.tsx b/packages/clay-core/src/table/Body.tsx index 4315362f95..225a7cb27d 100644 --- a/packages/clay-core/src/table/Body.tsx +++ b/packages/clay-core/src/table/Body.tsx @@ -58,7 +58,10 @@ function* flatten>( _size: array.length, } as unknown as T; - if (Array.isArray(array[i]![nestedKey])) { + if ( + Array.isArray(array[i]![nestedKey]) && + array[i]![nestedKey].length > 0 + ) { delete item[nestedKey]; // @ts-ignore item._expandable = true; From eb0c15a9f7a4e3f4418c6ad00868d3f297331900 Mon Sep 17 00:00:00 2001 From: Ilza Medeiros Date: Wed, 30 Oct 2024 15:40:46 -0300 Subject: [PATCH 2/2] fix(@clayui/core): LPD-39956 - Update tests --- .../__tests__/IncrementalInteractions.tsx | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/packages/clay-core/src/table/__tests__/IncrementalInteractions.tsx b/packages/clay-core/src/table/__tests__/IncrementalInteractions.tsx index 2592c9f631..a67c7c7470 100644 --- a/packages/clay-core/src/table/__tests__/IncrementalInteractions.tsx +++ b/packages/clay-core/src/table/__tests__/IncrementalInteractions.tsx @@ -37,6 +37,21 @@ const itemsTree = [ }, ]; +const emptyStateItems = [ + { + id: 1, + name: 'Foo', + type: 'PNG', + }, + {id: 2, name: 'Bar', type: 'Files'}, + { + children: [], + id: 3, + name: 'Baz', + type: 'Folder', + }, +]; + describe('Table incremental interactions', () => { afterEach(cleanup); @@ -479,6 +494,35 @@ describe('Table incremental interactions', () => { expect(thirdRow!.getAttribute('aria-expanded')).toBe('false'); }); + it('does not render left arrow button when child array is empty', () => { + const {queryByRole} = render( + + + {(column) => ( + {column.name} + )} + + + + {(row) => ( + + {(column) => ( + + {/** @ts-ignore */} + {row[column.id]} + + )} + + )} + +
+ ); + + const buttonRole = queryByRole('presentation'); + + expect(buttonRole).not.toBeInTheDocument(); + }); + it('pressing the left arrow key moves the focus to the row on the level above', () => { const {getAllByRole} = render(