Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): 悬停角头单元格后显示图标 #2261

Merged
merged 5 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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