Skip to content

Commit

Permalink
fix(core): 悬停角头单元格后显示图标 (#2261)
Browse files Browse the repository at this point in the history
Co-authored-by: Jinke Li <[email protected]>
  • Loading branch information
d2FuZ3h1ZG9uZw and lijinke666 authored Jul 7, 2023
1 parent 589ebb5 commit 2d85d57
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Array [
"extra": undefined,
"field": "province",
"height": 30,
"id": "",
"id": "province",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -39,7 +39,7 @@ Array [
"extra": undefined,
"field": "city",
"height": 30,
"id": "",
"id": "city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -102,7 +102,7 @@ Array [
"extra": undefined,
"field": "province",
"height": 30,
"id": "",
"id": "province",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -131,7 +131,7 @@ Array [
"extra": undefined,
"field": "city",
"height": 30,
"id": "",
"id": "city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -165,7 +165,7 @@ Array [
"extra": undefined,
"field": undefined,
"height": 30,
"id": "",
"id": "province/city/数值",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -228,7 +228,7 @@ Array [
"extra": undefined,
"field": undefined,
"height": 30,
"id": "",
"id": "province/city/数值",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -262,7 +262,7 @@ Array [
"extra": undefined,
"field": "province",
"height": 30,
"id": "",
"id": "province",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -291,7 +291,7 @@ Array [
"extra": undefined,
"field": "city",
"height": 30,
"id": "",
"id": "city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -354,7 +354,7 @@ Array [
"extra": undefined,
"field": "province",
"height": 30,
"id": "",
"id": "province",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -383,7 +383,7 @@ Array [
"extra": undefined,
"field": "city",
"height": 30,
"id": "",
"id": "city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -417,7 +417,7 @@ Array [
"extra": undefined,
"field": undefined,
"height": 30,
"id": "",
"id": "province/city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -480,7 +480,7 @@ Array [
"extra": undefined,
"field": undefined,
"height": 30,
"id": "",
"id": "province/city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -514,7 +514,7 @@ Array [
"extra": undefined,
"field": "province",
"height": 30,
"id": "",
"id": "province",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -543,7 +543,7 @@ Array [
"extra": undefined,
"field": "city",
"height": 30,
"id": "",
"id": "city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -606,7 +606,7 @@ Array [
"extra": undefined,
"field": "province",
"height": 30,
"id": "",
"id": "province",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -635,7 +635,7 @@ Array [
"extra": undefined,
"field": "city",
"height": 30,
"id": "",
"id": "city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -669,7 +669,7 @@ Array [
"extra": undefined,
"field": undefined,
"height": 30,
"id": "",
"id": "province/city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down Expand Up @@ -732,7 +732,7 @@ Array [
"extra": undefined,
"field": undefined,
"height": 30,
"id": "",
"id": "province/city",
"inCollapseNode": undefined,
"isCollapsed": undefined,
"isGrandTotals": undefined,
Expand Down
4 changes: 1 addition & 3 deletions packages/s2-core/src/cell/corner-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
} from '../utils/interaction/resize';
import { isIPhoneX } from '../utils/is-mobile';
import { getEllipsisText, getEmptyPlaceholder } from '../utils/text';
import { i18n } from './../common/i18n';
import { shouldAddResizeArea } from './../utils/interaction/resize';
import { HeaderCell } from './header-cell';

Expand All @@ -54,8 +53,6 @@ export class CornerCell extends HeaderCell {
return CellTypes.CORNER_CELL;
}

public update() {}

protected initCell() {
super.initCell();
this.resetTextAndConditionIconShapes();
Expand All @@ -66,6 +63,7 @@ export class CornerCell extends HeaderCell {
this.drawActionIcons();
this.drawBorderShape();
this.drawResizeArea();
this.update();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/s2-core/src/cell/header-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,11 @@ export abstract class HeaderCell extends BaseCell<Node> {
const { interaction } = this.spreadsheet;
const stateInfo = interaction?.getState();
const cells = interaction?.getCells([
CellTypes.CORNER_CELL,
CellTypes.COL_CELL,
CellTypes.ROW_CELL,
]);

if (!first(cells)) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/s2-core/src/facet/header/corner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class CornerHeader extends BaseHeader<CornerHeaderConfig> {

const cNode: Node = new Node({
key: '',
id: '',
id: cornerText,
value: cornerText,
});
cNode.x = position.x + seriesNumberWidth;
Expand All @@ -154,7 +154,7 @@ export class CornerHeader extends BaseHeader<CornerHeaderConfig> {
const field = rows[rowNode.level];
const cNode: Node = new Node({
key: field,
id: '',
id: field,
value: dataSet.getFieldName(field),
});

Expand All @@ -176,7 +176,7 @@ export class CornerHeader extends BaseHeader<CornerHeaderConfig> {
const field = columns[colNode.level];
const cNode: Node = new Node({
key: field,
id: '',
id: field,
value: dataSet.getFieldName(field),
});
cNode.x = position.x;
Expand Down
3 changes: 1 addition & 2 deletions packages/s2-core/src/interaction/base-interaction/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ export class HoverEvent extends BaseEvent implements BaseEventImplement {

public bindCornerCellHover() {
this.spreadsheet.on(S2Event.CORNER_CELL_HOVER, (event: CanvasEvent) => {
const cell = this.spreadsheet.getCell(event.target);
this.showEllipsisTooltip(event, cell);
this.handleHeaderHover(event);
});
}
}
17 changes: 17 additions & 0 deletions packages/s2-react/playground/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ export const s2Options: SheetComponentOptions = {
},
],
},
headerActionIcons: [
{
iconNames: ['SortDown'],
belongsCell: 'colCell',
defaultHide: true,
},
{
iconNames: ['SortDown'],
belongsCell: 'rowCell',
defaultHide: true,
},
{
iconNames: ['SortDown'],
belongsCell: 'cornerCell',
defaultHide: true,
},
],
hierarchyType: 'grid',
style: {
colCfg: {
Expand Down

1 comment on commit 2d85d57

@vercel
Copy link

@vercel vercel bot commented on 2d85d57 Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

antvis-s2 – ./

antvis-s2.vercel.app
antvis-s2-git-master-antv-s2.vercel.app
antvis-s2-antv-s2.vercel.app

Please sign in to comment.