Skip to content

Commit 42cc616

Browse files
committed
fix: table column resize for scroll, close #4811
1 parent 15d4b2e commit 42cc616

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

components/vc-table/Header/DragHandle.tsx

+3-32
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
import addEventListenerWrap from '../../vc-util/Dom/addEventListener';
22
import type { EventHandler } from '../../_util/EventInterface';
33
import raf from '../../_util/raf';
4-
import {
5-
defineComponent,
6-
onUnmounted,
7-
nextTick,
8-
watch,
9-
computed,
10-
ref,
11-
watchEffect,
12-
getCurrentInstance,
13-
onMounted,
14-
} from 'vue';
4+
import { defineComponent, onUnmounted, computed, ref, watchEffect, getCurrentInstance } from 'vue';
155
import type { PropType } from 'vue';
166
import devWarning from '../../vc-util/devWarning';
177
import type { ColumnType } from '../interface';
@@ -81,13 +71,7 @@ export default defineComponent({
8171
: Infinity;
8272
});
8373
const instance = getCurrentInstance();
84-
// eslint-disable-next-line vue/no-setup-props-destructure
85-
let baseWidth = props.width;
86-
onMounted(() => {
87-
nextTick(() => {
88-
baseWidth = instance.vnode.el?.parentNode?.getBoundingClientRect().width;
89-
});
90-
});
74+
let baseWidth = 0;
9175
const dragging = ref(false);
9276
let rafId: number;
9377
const updateWidth = (e: HandleEvent) => {
@@ -117,15 +101,12 @@ export default defineComponent({
117101
const handleStop = (e: HandleEvent) => {
118102
dragging.value = false;
119103
updateWidth(e);
120-
nextTick(() => {
121-
baseWidth = instance.vnode.el?.parentNode?.getBoundingClientRect().width;
122-
});
123104
removeEvents();
124105
};
125106
const handleStart = (e: HandleEvent, eventsFor: any) => {
126107
dragging.value = true;
127108
removeEvents();
128-
109+
baseWidth = instance.vnode.el.parentNode.getBoundingClientRect().width;
129110
if (e instanceof MouseEvent && e.which !== 1) {
130111
return;
131112
}
@@ -150,16 +131,6 @@ export default defineComponent({
150131
e.preventDefault();
151132
};
152133

153-
watch(
154-
() => props.width,
155-
() => {
156-
if (!dragging.value) {
157-
baseWidth = props.width;
158-
}
159-
},
160-
{ immediate: true },
161-
);
162-
163134
return () => {
164135
const { prefixCls } = props;
165136
const touchEvents = {

0 commit comments

Comments
 (0)