fix: delete Popconfirm being obscured by fixed columns (#6118)

* fix: delete Popconfirm being obscured by fixed columns

* fix: opened popConfirm will prevent the table from scrolling

---------

Co-authored-by: Netfan <netfan@foxmail.com>
This commit is contained in:
Leeson 2025-05-06 22:33:17 +08:00 committed by GitHub
parent cc6c9bf7a0
commit 5949c73a30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -208,22 +208,34 @@ setupVbenVxeTable({
} }
function renderConfirm(opt: Recordable<any>) { function renderConfirm(opt: Recordable<any>) {
let viewportWrapper: HTMLElement | null = null;
return h( return h(
Popconfirm, Popconfirm,
{ {
getPopupContainer(el) { /**
return ( * popconfirm用在固定列中时
el *
.closest('.vxe-table--viewport-wrapper') * body或者表格视口区域作为弹窗容器时又会导致弹窗无法跟随表格滚动
?.querySelector('.vxe-table--main-wrapper') *
?.querySelector('tbody') || document.body *
); */
getPopupContainer() {
viewportWrapper = el.closest('.vxe-table--viewport-wrapper');
return document.body;
}, },
placement: 'topLeft', placement: 'topLeft',
title: $t('ui.actionTitle.delete', [attrs?.nameTitle || '']), title: $t('ui.actionTitle.delete', [attrs?.nameTitle || '']),
...props, ...props,
...opt, ...opt,
icon: undefined, icon: undefined,
onOpenChange: (open: boolean) => {
// 当弹窗打开时,禁止表格的滚动
if (open) {
viewportWrapper?.style.setProperty('pointer-events', 'none');
} else {
viewportWrapper?.style.removeProperty('pointer-events');
}
},
onConfirm: () => { onConfirm: () => {
attrs?.onClick?.({ attrs?.onClick?.({
code: opt.code, code: opt.code,