From f15403f0544b6274e74d471a2ad3bd16e5fcff8a Mon Sep 17 00:00:00 2001 From: Gavin Everett Date: Tue, 8 Oct 2024 11:12:02 +0100 Subject: [PATCH] fix(table-toolbar): fix console errors when slots are absent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix console errors when slots are absent ✅ Closes: COMUI-3148 --- .../gux-table-toolbar/gux-table-toolbar.service.ts | 7 ++++++- .../stable/gux-table-toolbar/gux-table-toolbar.tsx | 11 +++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.service.ts b/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.service.ts index a2a0ffc662..1885252166 100644 --- a/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.service.ts +++ b/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.service.ts @@ -21,6 +21,11 @@ export function setActionsIconOnlyProp( ): void { actionSets .flat() - .filter(action => action !== null && !action.hasAttribute('icon-only')) + .filter( + action => + action !== null && + action !== undefined && + !action?.hasAttribute('icon-only') + ) .forEach(action => (action.iconOnly = iconOnly)); } diff --git a/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.tsx b/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.tsx index 304f2aec76..bff3e460e7 100644 --- a/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.tsx +++ b/packages/genesys-spark-components/src/components/stable/gux-table-toolbar/gux-table-toolbar.tsx @@ -98,7 +98,7 @@ export class GuxTableToolbar { return this.root?.querySelector('gux-table-toolbar-custom-action[slot]'); } - get permanentActions(): HTMLGuxTableToolbarCustomActionElement[] | null { + get permanentActions(): HTMLGuxTableToolbarCustomActionElement[] { if (this.permanentSlot?.hasChildNodes) { return Array.from( this.permanentSlot?.querySelectorAll( @@ -106,6 +106,7 @@ export class GuxTableToolbar { ) ); } + return []; } get menuActionsItems(): HTMLGuxTableToolbarCustomActionElement[] | null { @@ -118,7 +119,7 @@ export class GuxTableToolbar { } } - get contextualActions(): HTMLGuxTableToolbarCustomActionElement[] | null { + get contextualActions(): HTMLGuxTableToolbarCustomActionElement[] { if (this.contextualSlot?.hasChildNodes) { return Array.from( this.contextualSlot?.querySelectorAll( @@ -126,9 +127,10 @@ export class GuxTableToolbar { ) ); } + return []; } - get filterActions(): HTMLGuxTableToolbarCustomActionElement[] | null { + get filterActions(): HTMLGuxTableToolbarCustomActionElement[] { if (this.filterSlot?.hasChildNodes) { return Array.from( this.filterSlot?.querySelectorAll( @@ -136,9 +138,10 @@ export class GuxTableToolbar { ) ); } + return []; } - get allFilterContextual(): HTMLGuxTableToolbarCustomActionElement[] | null { + get allFilterContextual(): HTMLGuxTableToolbarCustomActionElement[] { return this.filterActions?.concat(this.contextualActions); }