Skip to content

Commit

Permalink
Merge pull request #1932 from VisActor/feat/add-deselect-option
Browse files Browse the repository at this point in the history
Feat/add deselect option
  • Loading branch information
fangsmile committed Jun 17, 2024
2 parents 7bb8677 + a162694 commit fc7b6d3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: add blankAreaClickDeselect and outsideClickDeselect config\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
8 changes: 8 additions & 0 deletions docs/assets/option/en/common/option-secondary.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ Do not respond to mouse select interaction.

Separately set the header not to respond to mouse select interaction.

##${prefix} blankAreaClickDeselect(boolean) = false

Whether to cancel the selection when clicking the blank area.

##${prefix} outsideClickDeselect(boolean) = true

Whether to cancel the selection when clicking outside the table.

#${prefix} theme(Object)

{{ use: common-theme(
Expand Down
1 change: 1 addition & 0 deletions docs/assets/option/en/table/listTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Whether to transpose, default is false
Whether to display the table header.
## pagination(IPagination)
Pagination configuration.
Expand Down
8 changes: 8 additions & 0 deletions docs/assets/option/zh/common/option-secondary.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ hover 交互响应模式:十字交叉、整列、整行或者单个单元格

单独设置表头不响应鼠标 select 交互。

##${prefix} blankAreaClickDeselect(boolean) = false

点击空白区域是否取消选中。

##${prefix} outsideClickDeselect(boolean) = true

点击外部区域是否取消选中。

#${prefix} theme(Object)

{{ use: common-theme(
Expand Down
13 changes: 10 additions & 3 deletions packages/vtable/src/event/listener/table-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { SceneEvent } from '../util';
import { getCellEventArgsSet, regIndexReg } from '../util';
import { TABLE_EVENT_TYPE } from '../../core/TABLE_EVENT_TYPE';
import type { Group } from '../../scenegraph/graphic/group';
import { isValid, last } from '@visactor/vutils';
import { isValid } from '@visactor/vutils';
import { getIconAndPositionFromTarget } from '../../scenegraph/utils/icon';
import { cellInRanges } from '../../tools/helper';
import { Rect } from '../../tools/Rect';
Expand Down Expand Up @@ -338,7 +338,9 @@ export function bindTableGroupListener(eventManager: EventManager) {
stateManager.updateInteractionState(InteractionState.default);
eventManager.dealTableHover();
//点击到表格外部不需要取消选中状态
// eventManager.dealTableSelect();
if (table.options.select?.outsideClickDeselect) {
eventManager.dealTableSelect();
}
});

table.scenegraph.tableGroup.addEventListener('pointerdown', (e: FederatedPointerEvent) => {
Expand Down Expand Up @@ -729,8 +731,13 @@ export function bindTableGroupListener(eventManager: EventManager) {
) {
stateManager.updateInteractionState(InteractionState.default);
eventManager.dealTableHover();
eventManager.dealTableSelect();
stateManager.endSelectCells();

// 点击空白区域取消选中
if (table.options.select?.blankAreaClickDeselect ?? true) {
eventManager.dealTableSelect();
}

stateManager.updateCursor();
table.scenegraph.updateChartState(null);
} else if (table.eventManager.isDraging && stateManager.isSelecting()) {
Expand Down
4 changes: 4 additions & 0 deletions packages/vtable/src/ts-types/base-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ export interface BaseTableConstructorOptions {
disableSelect?: boolean;
/** 单独设置表头不响应鼠标select交互 */
disableHeaderSelect?: boolean;
/** 点击空白区域是否取消选中 */
blankAreaClickDeselect?: boolean;
/** 点击外部区域是否取消选中 */
outsideClickDeselect?: boolean; //
};
/** 下拉菜单的相关配置。消失时机:显示后点击菜单区域外自动消失*/
menu?: {
Expand Down

0 comments on commit fc7b6d3

Please sign in to comment.