From d4b559e1010e8cc200dbd322cff44e2b70a842c5 Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Tue, 19 Dec 2023 11:39:11 +0800 Subject: [PATCH 1/5] fix: dropdown_menu_click trigger #760 --- packages/vtable/examples/interactive/menu.ts | 5 ++++- packages/vtable/src/event/listener/table-group.ts | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/vtable/examples/interactive/menu.ts b/packages/vtable/examples/interactive/menu.ts index 9f3de4506..5f6b57fc3 100644 --- a/packages/vtable/examples/interactive/menu.ts +++ b/packages/vtable/examples/interactive/menu.ts @@ -181,7 +181,10 @@ export function createTable() { // instance.showDropDownMenu(col, row, { // content: ['a', 'b'] // }); - + instance.on('dropdown_menu_click', args => { + console.log('dropdown_menu_click', args); + instance.setDropDownMenuHighlight([args]); + }); // 只为了方便控制太调试用,不要拷贝 window.tableInstance = instance; } diff --git a/packages/vtable/src/event/listener/table-group.ts b/packages/vtable/src/event/listener/table-group.ts index 69c01b7f1..7b7ede83b 100644 --- a/packages/vtable/src/event/listener/table-group.ts +++ b/packages/vtable/src/event/listener/table-group.ts @@ -285,7 +285,9 @@ export function bindTableGroupListener(eventManager: EventManager) { table.scenegraph.tableGroup.addEventListener('pointerupoutside', (e: FederatedPointerEvent) => { const eventArgsSet: SceneEvent = getCellEventArgsSet(e); if (stateManager.menu.isShow && (eventArgsSet.eventArgs?.target as any) !== stateManager.residentHoverIcon?.icon) { - stateManager.hideMenu(); + setTimeout(() => { + stateManager.menu.isShow && stateManager.hideMenu(); + }, 0); } // 同pointerup中的逻辑 if (stateManager.isResizeCol()) { From 5962119a08330f95efdc8c086f7d4755c9b5f3cd Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Tue, 19 Dec 2023 11:39:29 +0800 Subject: [PATCH 2/5] docs: update changlog of rush --- .../760-bug-dropdown_menu_click_2023-12-19-03-39.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-03-39.json diff --git a/common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-03-39.json b/common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-03-39.json new file mode 100644 index 000000000..d43ae8c73 --- /dev/null +++ b/common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-03-39.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: dropdown_menu_click trigger #760\n\n", + "type": "none", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "892739385@qq.com" +} \ No newline at end of file From 018a51a4bacc1abea2a5233883b2526979febdd0 Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Tue, 19 Dec 2023 12:02:15 +0800 Subject: [PATCH 3/5] fix: dblclick occur error #758 --- packages/vtable/src/core/BaseTable.ts | 32 ++++++++++--------- .../vtable/src/event/listener/table-group.ts | 19 +++++++---- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/packages/vtable/src/core/BaseTable.ts b/packages/vtable/src/core/BaseTable.ts index 2827479fc..ad9f308f1 100644 --- a/packages/vtable/src/core/BaseTable.ts +++ b/packages/vtable/src/core/BaseTable.ts @@ -2784,21 +2784,23 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { } /** 获取单元格的基本信息 目前主要组织单元格信息给事件传递给用户的参数使用 */ getCellInfo(col: number, row: number): Omit { - const colDef = this.isHeader(col, row) ? this.getHeaderDefine(col, row) : this.getBodyColumnDefine(col, row); - return { - col, - row, - field: this.getHeaderField(col, row), - cellHeaderPaths: this.internalProps.layoutMap.getCellHeaderPaths(col, row), - title: colDef?.title, - cellType: colDef?.cellType ? (typeof colDef.cellType === 'string' ? colDef.cellType : 'progressbar') : 'text', - originData: this.getCellOriginRecord(col, row), - cellRange: this.getCellRangeRelativeRect({ col, row }), - value: this.getCellValue(col, row), - dataValue: this.getCellOriginValue(col, row), - cellLocation: this.getCellLocation(col, row), - scaleRatio: this.canvas.getBoundingClientRect().width / this.canvas.offsetWidth - }; + if (col >= 0 && row >= 0) { + const colDef = this.isHeader(col, row) ? this.getHeaderDefine(col, row) : this.getBodyColumnDefine(col, row); + return { + col, + row, + field: this.getHeaderField(col, row), + cellHeaderPaths: this.internalProps.layoutMap.getCellHeaderPaths(col, row), + title: colDef?.title, + cellType: colDef?.cellType ? (typeof colDef.cellType === 'string' ? colDef.cellType : 'progressbar') : 'text', + originData: this.getCellOriginRecord(col, row), + cellRange: this.getCellRangeRelativeRect({ col, row }), + value: this.getCellValue(col, row), + dataValue: this.getCellOriginValue(col, row), + cellLocation: this.getCellLocation(col, row), + scaleRatio: this.canvas.getBoundingClientRect().width / this.canvas.offsetWidth + }; + } } /** @private */ _hasField(field: FieldDef, col: number, row: number): boolean { diff --git a/packages/vtable/src/event/listener/table-group.ts b/packages/vtable/src/event/listener/table-group.ts index 7b7ede83b..02f3dbe49 100644 --- a/packages/vtable/src/event/listener/table-group.ts +++ b/packages/vtable/src/event/listener/table-group.ts @@ -723,13 +723,20 @@ function endResizeCol(table: BaseTableAPI) { function dblclickHandler(e: FederatedPointerEvent, table: BaseTableAPI) { const eventArgsSet: SceneEvent = getCellEventArgsSet(e); - const bounds = eventArgsSet.eventArgs.targetCell.globalAABBBounds; - const { col, row } = eventArgsSet.eventArgs; + let col = -1; + let row = -1; + if (eventArgsSet.eventArgs) { + col = eventArgsSet.eventArgs.col; + row = eventArgsSet.eventArgs.row; + } const value = table.getCellValue(col, row); - table.internalProps.focusControl.setFocusRect( - new Rect(bounds.x1 + table.scrollLeft, bounds.y1 + table.scrollTop, bounds.x2 - bounds.x1, bounds.y2 - bounds.y1), - value - ); + + const bounds = eventArgsSet.eventArgs?.targetCell?.globalAABBBounds; + bounds && + table.internalProps.focusControl.setFocusRect( + new Rect(bounds.x1 + table.scrollLeft, bounds.y1 + table.scrollTop, bounds.x2 - bounds.x1, bounds.y2 - bounds.y1), + value + ); if ((table as any).hasListeners(TABLE_EVENT_TYPE.DBLCLICK_CELL)) { const cellInfo = table.getCellInfo(col, row); let icon; From 6f164e500bc7b974d4d87310d32f848b02e4b0e3 Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Tue, 19 Dec 2023 12:02:43 +0800 Subject: [PATCH 4/5] docs: update changlog of rush --- .../760-bug-dropdown_menu_click_2023-12-19-04-02.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-04-02.json diff --git a/common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-04-02.json b/common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-04-02.json new file mode 100644 index 000000000..909832cbe --- /dev/null +++ b/common/changes/@visactor/vtable/760-bug-dropdown_menu_click_2023-12-19-04-02.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: dblclick occur error #758\n\n", + "type": "none", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "892739385@qq.com" +} \ No newline at end of file From 01872d0a8148c84b6ec164dc4b445c8a4479a11c Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Tue, 19 Dec 2023 12:07:19 +0800 Subject: [PATCH 5/5] fix: dblclick occur error #758 --- packages/vtable/src/core/BaseTable.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vtable/src/core/BaseTable.ts b/packages/vtable/src/core/BaseTable.ts index ad9f308f1..5dd0ddd64 100644 --- a/packages/vtable/src/core/BaseTable.ts +++ b/packages/vtable/src/core/BaseTable.ts @@ -2801,6 +2801,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { scaleRatio: this.canvas.getBoundingClientRect().width / this.canvas.offsetWidth }; } + return undefined; } /** @private */ _hasField(field: FieldDef, col: number, row: number): boolean {