Skip to content

Commit 508e8e3

Browse files
committed
fix: paginantion error, close #6590
1 parent fe3c2bd commit 508e8e3

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

components/_util/PortalWrapper.tsx

+13-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const getParent = (getContainer: GetContainer) => {
3030
}
3131
if (getContainer) {
3232
if (typeof getContainer === 'string') {
33-
return document.querySelectorAll(getContainer)[0];
33+
return document.querySelectorAll(getContainer)[0] as HTMLElement;
3434
}
3535
if (typeof getContainer === 'function') {
3636
return getContainer();
@@ -68,9 +68,10 @@ export default defineComponent({
6868
container.value?.parentNode?.removeChild(container.value);
6969
container.value = null;
7070
};
71+
let parent: HTMLElement = null;
7172
const attachToParent = (force = false) => {
7273
if (force || (container.value && !container.value.parentNode)) {
73-
const parent = getParent(props.getContainer);
74+
parent = getParent(props.getContainer);
7475
if (parent) {
7576
parent.appendChild(container.value);
7677
return true;
@@ -123,11 +124,14 @@ export default defineComponent({
123124
[() => props.visible, () => props.getContainer],
124125
([visible, getContainer], [prevVisible, prevGetContainer]) => {
125126
// Update count
126-
if (supportDom && getParent(props.getContainer) === document.body) {
127-
if (visible && !prevVisible) {
128-
openCount += 1;
129-
} else if (init) {
130-
openCount -= 1;
127+
if (supportDom) {
128+
parent = getParent(props.getContainer);
129+
if (parent === document.body) {
130+
if (visible && !prevVisible) {
131+
openCount += 1;
132+
} else if (init) {
133+
openCount -= 1;
134+
}
131135
}
132136
}
133137

@@ -158,8 +162,8 @@ export default defineComponent({
158162
});
159163

160164
onBeforeUnmount(() => {
161-
const { visible, getContainer } = props;
162-
if (supportDom && getParent(getContainer) === document.body) {
165+
const { visible } = props;
166+
if (supportDom && parent === document.body) {
163167
// 离开时不会 render, 导到离开时数值不变,改用 func 。。
164168
openCount = visible && openCount ? openCount - 1 : openCount;
165169
}

0 commit comments

Comments
 (0)