Skip to content

Commit c38b6dd

Browse files
committed
feat(interaction): 只有点击列头时才显示隐藏按钮
1 parent 5c7fa35 commit c38b6dd

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

packages/s2-core/src/interaction/base-interaction/click/row-column-click.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import {
1313
InteractionStateName,
1414
TOOLTIP_OPERATOR_MENUS,
1515
InterceptType,
16+
CellTypes,
1617
} from '@/common/constant';
17-
import { TooltipOperatorOptions } from '@/common/interface';
18+
import { TooltipOperation, TooltipOperatorOptions } from '@/common/interface';
1819
import { Node } from '@/facet/layout/node';
1920
import { mergeCellInfo, getTooltipOptions } from '@/utils/tooltip';
2021

@@ -135,21 +136,31 @@ export class RowColumnClick extends BaseEvent implements BaseEventImplement {
135136
? mergeCellInfo(interaction.getActiveCells())
136137
: [];
137138

138-
// 当只有一个列头时, 不显示隐藏按钮
139-
const isMultiColumns = this.spreadsheet.getColumnNodes().length > 1;
139+
const operator = this.getTooltipOperator(event, operation);
140+
this.spreadsheet.showTooltipWithInfo(event, cellInfos, {
141+
showSingleTips: true,
142+
operator,
143+
});
144+
}
140145

141-
const operator: TooltipOperatorOptions = operation.hiddenColumns &&
146+
private getTooltipOperator(
147+
event: CanvasEvent,
148+
operation: TooltipOperation,
149+
): TooltipOperatorOptions {
150+
const cellType = this.spreadsheet.getCellType(event.target);
151+
const isColCell = cellType === CellTypes.COL_CELL;
152+
// 是列头单元格, 且大于一个时, 显示隐藏按钮
153+
const isMultiColumns =
154+
isColCell && this.spreadsheet.getColumnNodes().length > 1;
155+
156+
const operator = operation.hiddenColumns &&
142157
isMultiColumns && {
143158
onClick: () => {
144159
this.hideSelectedColumns();
145160
},
146161
menus: TOOLTIP_OPERATOR_MENUS.HiddenColumns,
147162
};
148-
149-
this.spreadsheet.showTooltipWithInfo(event, cellInfos, {
150-
showSingleTips: true,
151-
operator,
152-
});
163+
return operator;
153164
}
154165

155166
private bindTableColExpand() {

0 commit comments

Comments
 (0)