Skip to content

Commit be88bbb

Browse files
committed
Fix: Refactor showContextMenu logic
1 parent 6ee83a4 commit be88bbb

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

packages/components/src/components/hds/advanced-table/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,12 @@ export default class HdsAdvancedTable extends Component<HdsAdvancedTableSignatur
661661
private _isStickyColumn = (
662662
column: HdsAdvancedTableColumnType
663663
): boolean | undefined => {
664-
if (this.hasStickyFirstColumn && column.isFirst) {
665-
return true;
666-
} else if (this.hasStickyFirstColumn === false) {
667-
return false;
664+
if (column.isFirst) {
665+
if (this.hasStickyFirstColumn) {
666+
return true;
667+
} else if (this.hasStickyFirstColumn === false) {
668+
return false;
669+
}
668670
}
669671
return undefined;
670672
};

packages/components/src/components/hds/advanced-table/th-sort.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,9 @@ export default class HdsAdvancedTableThSort extends Component<HdsAdvancedTableTh
101101
}
102102

103103
get showContextMenu(): boolean {
104-
const { column, isStickyColumn, hasResizableColumns } = this.args;
104+
const { hasResizableColumns, isStickyColumn } = this.args;
105105

106-
return (
107-
(hasResizableColumns ||
108-
(isStickyColumn !== undefined && column && column.isFirst)) ??
109-
false
110-
);
106+
return (hasResizableColumns || isStickyColumn !== undefined) ?? false;
111107
}
112108

113109
get classNames(): string {

packages/components/src/components/hds/advanced-table/th.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,9 @@ export default class HdsAdvancedTableTh extends Component<HdsAdvancedTableThSign
144144
}
145145

146146
get showContextMenu(): boolean {
147-
const { column, isStickyColumn, hasResizableColumns } = this.args;
147+
const { hasResizableColumns, isStickyColumn } = this.args;
148148

149-
return (
150-
(hasResizableColumns ||
151-
(isStickyColumn !== undefined && column && column.isFirst)) ??
152-
false
153-
);
149+
return (hasResizableColumns || isStickyColumn !== undefined) ?? false;
154150
}
155151

156152
@action onFocusTrapDeactivate(): void {

0 commit comments

Comments
 (0)