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: outsideClickDeselect event in menu element #3012

Merged
merged 3 commits into from
Dec 6, 2024
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
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: outsideClickDeselect event in menu element",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
3 changes: 3 additions & 0 deletions packages/vtable/src/components/menu/dom/BaseMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ export abstract class BaseMenu {
const menuElement = this._getMenuElement();
return menuElement.pointInMenuElement(x, y);
}
getRootElement(): HTMLElement {
return this._getMenuElement().rootElement;
}
}
10 changes: 10 additions & 0 deletions packages/vtable/src/components/menu/dom/MenuHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,14 @@ export class MenuHandler {
info
};
}

containElement(el: HTMLElement): boolean {
for (const k in this._menuInstances) {
const contain = this._menuInstances[k].getRootElement()?.contains(el);
if (contain) {
return true;
}
}
return false;
}
}
2 changes: 1 addition & 1 deletion packages/vtable/src/event/listener/table-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export function bindTableGroupListener(eventManager: EventManager) {
};
const globalPointerdownCallback = (e: MouseEvent) => {
const target = e.target as HTMLElement;
if (!table.getElement().contains(target)) {
if (!table.getElement().contains(target) && !table.internalProps.menuHandler.containElement(target)) {
// 如果点击到表格外部的dom
const isCompleteEdit = (table as ListTableAPI).editorManager?.completeEdit(e);
getPromiseValue<boolean>(isCompleteEdit, isCompleteEdit => {
Expand Down
40 changes: 20 additions & 20 deletions packages/vtable/src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,27 +332,27 @@ const builtins = {
cursor: 'pointer'
};
},
//loading状态按钮
get loading(): ImageIcon {
return {
type: 'image',
src: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/media/loading-circle.gif',
width: collapse_size,
height: collapse_size,
name: 'loading',
positionType: IconPosition.contentLeft,
marginLeft: 0,
marginRight: 4,
hover: {
width: collapse_size_2,
height: collapse_size_2,
bgColor: 'rgba(101, 117, 168, 0.1)'
},
// cursor: 'pointer',
// //loading状态按钮
// get loading(): ImageIcon {
// return {
// type: 'image',
// src: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/media/loading-circle.gif',
// width: collapse_size,
// height: collapse_size,
// name: 'loading',
// positionType: IconPosition.contentLeft,
// marginLeft: 0,
// marginRight: 4,
// hover: {
// width: collapse_size_2,
// height: collapse_size_2,
// bgColor: 'rgba(101, 117, 168, 0.1)'
// },
// // cursor: 'pointer',

isGif: true
};
},
// isGif: true
// };
// },

// drill按钮
get drillDown(): SvgIcon {
Expand Down
7 changes: 6 additions & 1 deletion packages/vtable/src/scenegraph/group-creater/cell-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,12 @@ export function updateCell(

// update text
const textMark = oldCellGroup.getChildByName('text');
if (textMark) {
if (forceFastUpdate && textMark) {
const attribute = {
textBaseline: 'top'
};
textMark.setAttributes(cellTheme.text ? (Object.assign({}, cellTheme.text, attribute) as any) : attribute);
} else if (textMark) {
const text = table.getCellValue(col, row);
const { text: textArr, moreThanMaxCharacters } = breakString(text, table);

Expand Down
Loading