Skip to content

Commit

Permalink
fix: portal error, close #6880 #6837 #6807
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Aug 30, 2023
1 parent 6c13c96 commit 72e148c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
20 changes: 6 additions & 14 deletions components/_util/Portal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import PropTypes from './vue-types';
import {
defineComponent,
nextTick,
onBeforeMount,
onBeforeUnmount,
onUpdated,
Teleport,
watch,
} from 'vue';
import { defineComponent, nextTick, onBeforeMount, onUpdated, Teleport, watch } from 'vue';
import { useInjectPortal } from '../vc-trigger/context';

export default defineComponent({
Expand Down Expand Up @@ -44,11 +36,11 @@ export default defineComponent({
}
});
});
onBeforeUnmount(() => {
if (container && container.parentNode) {
container.parentNode.removeChild(container);
}
});
// onBeforeUnmount(() => {
// if (container && container.parentNode) {
// container.parentNode.removeChild(container);
// }
// });
return () => {
if (!shouldRender.value) return null;
if (isSSR) {
Expand Down
8 changes: 4 additions & 4 deletions components/_util/PortalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ export default defineComponent({
const container = shallowRef<HTMLElement>();
const componentRef = shallowRef();
const rafId = shallowRef<number>();

const defaultContainer = canUseDom() && document.createElement('div');
const removeCurrentContainer = () => {
// Portal will remove from `parentNode`.
// Let's handle this again to avoid refactor issue.
container.value?.parentNode?.removeChild(container.value);
if (container.value === defaultContainer) {
container.value?.parentNode?.removeChild(container.value);
}
container.value = null;
};
let parent: HTMLElement = null;
Expand All @@ -82,8 +84,6 @@ export default defineComponent({

return true;
};
// attachToParent();
const defaultContainer = canUseDom() && document.createElement('div');
const getContainer = () => {
if (!supportDom) {
return null;
Expand Down

0 comments on commit 72e148c

Please sign in to comment.