diff --git a/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts b/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts index 61bc961b03..988734c692 100644 --- a/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts +++ b/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts @@ -317,6 +317,7 @@ describe('Interaction Hover Tests', () => { await sleep(HOVER_FOCUS_DURATION + 200); expect(s2.showTooltipWithInfo).toHaveBeenCalled(); + expect(s2.hideTooltip).toHaveBeenCalled(); }, ); diff --git a/packages/s2-core/src/cell/base-cell.ts b/packages/s2-core/src/cell/base-cell.ts index 984712554a..28467f391f 100644 --- a/packages/s2-core/src/cell/base-cell.ts +++ b/packages/s2-core/src/cell/base-cell.ts @@ -138,7 +138,13 @@ export abstract class BaseCell extends Group { // TODO: 2.0 使用 G 内置的方法 public isTextOverflowing() { - return this.getActualText().includes(ELLIPSIS_SYMBOL); + const text = this.getActualText(); + if (text) { + return includes(text, ELLIPSIS_SYMBOL); + } + + // 多列文本, 或者自定义单元格等没有 textShape 的场景, 暂时还是保持原来的写法 + return text !== this.getFieldValue(); } public getFieldValue() { diff --git a/packages/s2-core/src/interaction/base-interaction/hover.ts b/packages/s2-core/src/interaction/base-interaction/hover.ts index 3e322e45ee..2f064a00aa 100644 --- a/packages/s2-core/src/interaction/base-interaction/hover.ts +++ b/packages/s2-core/src/interaction/base-interaction/hover.ts @@ -142,6 +142,7 @@ export class HoverEvent extends BaseEvent implements BaseEventImplement { private showEllipsisTooltip(event: CanvasEvent, cell: S2CellType) { if (!cell || !cell.isTextOverflowing()) { + this.spreadsheet.hideTooltip(); return; }