Browse Source

fix: setContainer in onBeforeMount for drawer (#6986)

* fix: setContainer in onBeforeMount for drawer

* fix: add judgement
pull/7025/head
Konv Suu 1 year ago committed by GitHub
parent
commit
449adb03df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      components/_util/Portal.tsx
  2. 3
      components/message/useMessage.tsx

16
components/_util/Portal.tsx

@ -23,14 +23,24 @@ export default defineComponent({
// getContainer
let container: HTMLElement;
const { shouldRender } = useInjectPortal();
function setContainer() {
if (shouldRender.value) {
container = props.getContainer();
}
}
onBeforeMount(() => {
isSSR = false;
// drawer
setContainer();
});
onMounted(() => {
if (shouldRender.value) {
container = props.getContainer();
}
if (container) return;
// https://github.com/vueComponent/ant-design-vue/issues/6937
setContainer();
});
const stopWatch = watch(shouldRender, () => {
if (shouldRender.value && !container) {
container = props.getContainer();

3
components/message/useMessage.tsx

@ -90,8 +90,7 @@ const Holder = defineComponent({
closable: false,
closeIcon: mergedCloseIcon,
duration: props.duration ?? DEFAULT_DURATION,
getContainer: () =>
props.staticGetContainer?.() || getPopupContainer.value?.() || document.body,
getContainer: props.staticGetContainer ?? getPopupContainer.value,
maxCount: props.maxCount,
onAllRemoved: props.onAllRemoved,
});

Loading…
Cancel
Save