Skip to content

Commit

Permalink
Merge pull request #649 from MyPureCloud/feature/COMUI-3148
Browse files Browse the repository at this point in the history
fix(table-toolbar): fix console errors when slots are absent
  • Loading branch information
gavin-everett-genesys authored Oct 9, 2024
2 parents dc6f0ae + f15403f commit e410f81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ 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(
'gux-table-toolbar-action, gux-table-toolbar-custom-action'
)
);
}
return [];
}

get menuActionsItems(): HTMLGuxTableToolbarCustomActionElement[] | null {
Expand All @@ -118,27 +119,29 @@ export class GuxTableToolbar {
}
}

get contextualActions(): HTMLGuxTableToolbarCustomActionElement[] | null {
get contextualActions(): HTMLGuxTableToolbarCustomActionElement[] {
if (this.contextualSlot?.hasChildNodes) {
return Array.from(
this.contextualSlot?.querySelectorAll(
'gux-table-toolbar-action, gux-table-toolbar-custom-action'
)
);
}
return [];
}

get filterActions(): HTMLGuxTableToolbarCustomActionElement[] | null {
get filterActions(): HTMLGuxTableToolbarCustomActionElement[] {
if (this.filterSlot?.hasChildNodes) {
return Array.from(
this.filterSlot?.querySelectorAll(
'gux-table-toolbar-action, gux-table-toolbar-custom-action'
)
);
}
return [];
}

get allFilterContextual(): HTMLGuxTableToolbarCustomActionElement[] | null {
get allFilterContextual(): HTMLGuxTableToolbarCustomActionElement[] {
return this.filterActions?.concat(this.contextualActions);
}

Expand Down

0 comments on commit e410f81

Please sign in to comment.