Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modal modal bug, ant-modal-wrap style does not have display: none in the test server environment, causing the page to be unclickable #4565

Closed
1 task
laijinxian opened this issue Aug 24, 2021 · 17 comments
Labels

Comments

@laijinxian
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.2.6

Environment

服务器, 谷歌浏览器,

Reproduction link

https://2x.antdv.com/components/modal-cn

Steps to reproduce

随意弹出弹窗,关闭后; 最外层原素有个 类名为ant-modal-root 的节点, 他下面有个 ant-modal-wrap 节点, 正式环境下 ant-modal-wrap 他会有display: none 属性, 测试环境就缺少这个样式导致整个页面无法点击

What is expected?

和正式环境一样 模态弹窗关闭后 ant-modal-wrap 应该要有 display: none 属性

What is actually happening?

ant-modal-wrap 缺少 display: none 属性

@github-actions github-actions bot changed the title modal 模态框bug,在test服务器环境下 ant-modal-wrap 样式没有 display: none, 导致页面无法点击 modal modal bug, ant-modal-wrap style does not have display: none in the test server environment, causing the page to be unclickable Aug 24, 2021
@laijinxian
Copy link
Author

123

@Damon-mac
Copy link

遇到了同样的问题...

@pengfeir
Copy link

同样的问题+1

@pengfeir
Copy link

watchEffect(() => {
const modelWrap:HTMLElement|null = document.querySelector('.ant-modal-wrap')
if (!visible.value && modelWrap) {
nextTick(() => {
modelWrap.style.display = 'none'
})
}
})暂时先这么搞

@So-For
Copy link

So-For commented Sep 16, 2021

I have the same problem now.And it occurs only in the test environment!!

@So-For
Copy link

So-For commented Sep 17, 2021

watchEffect(() => {
const modelWrap:HTMLElement|null = document.querySelector('.ant-modal-wrap')
if (!visible.value && modelWrap) {
nextTick(() => {
modelWrap.style.display = 'none'
})
}
})暂时先这么搞

When a page has Model elements more than two, there will still be the problem.
Improved code:

watchEffect(() => {
  const modelWrap: NodeList = document.querySelectorAll('.ant-modal-wrap');
  if (!state.modelVisible && modelWrap.length) {
    nextTick(() => {
      modelWrap.forEach((el: HTMLElement) => {
        el.style.display = 'none';
      });
    });
  }
});

@wulucxy
Copy link

wulucxy commented Sep 30, 2021

same problem +1

@wulucxy
Copy link

wulucxy commented Oct 8, 2021

@laijinxian 你是怎么解决了么

@wulucxy
Copy link

wulucxy commented Oct 8, 2021

问题解决了:
加上destroyOnClose 就有问题,不加没问题了

@nikolausliu
Copy link

这个issue为什么要关闭?bug修复了吗?2.2.0版本bug依然存在

@fearclear
Copy link

遇到了同样的问题,应该在这里出现了问题

export const getTransitionProps = (transitionName: string, opt: TransitionProps = {}) => {
if (process.env.NODE_ENV === 'test') {
return opt;
}
const transitionProps: TransitionProps = transitionName
? {
name: transitionName,
appear: true,
// type: 'animation',
// appearFromClass: `${transitionName}-appear ${transitionName}-appear-prepare`,
// appearActiveClass: `antdv-base-transtion`,
// appearToClass: `${transitionName}-appear ${transitionName}-appear-active`,
enterFromClass: `${transitionName}-enter ${transitionName}-enter-prepare`,
enterActiveClass: `${transitionName}-enter ${transitionName}-enter-prepare`,
enterToClass: `${transitionName}-enter ${transitionName}-enter-active`,
leaveFromClass: ` ${transitionName}-leave`,
leaveActiveClass: `${transitionName}-leave`,
leaveToClass: `${transitionName}-leave ${transitionName}-leave-active`,
...opt,
}
: { css: false, ...opt };
return transitionProps;
};
export const getTransitionGroupProps = (transitionName: string, opt: TransitionProps = {}) => {
const transitionProps: TransitionGroupProps = transitionName
? {
name: transitionName,
appear: true,
// appearFromClass: `${transitionName}-appear ${transitionName}-appear-prepare`,
appearActiveClass: `${transitionName}`,
appearToClass: `${transitionName}-appear ${transitionName}-appear-active`,
enterFromClass: `${transitionName}-appear ${transitionName}-enter ${transitionName}-appear-prepare ${transitionName}-enter-prepare`,
enterActiveClass: `${transitionName}`,
enterToClass: `${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-active ${transitionName}-enter-active`,
leaveActiveClass: `${transitionName} ${transitionName}-leave`,
leaveToClass: `${transitionName}-leave-active`,
...opt,
}
: { css: false, ...opt };
return transitionProps;
};
let Transition = T;
let TransitionGroup = TG;
if (process.env.NODE_ENV === 'test') {
let warn = true;
Transition = defineComponent({
name: 'TransitionForTest',
inheritAttrs: false,
setup(_props, { slots, attrs }) {
const instance = getCurrentInstance();
if (warn) {
console.warn('application runing at test env, you should build use production env');
warn = false;
}
onUpdated(() => {
const child = instance.subTree.children[0];
if (child && child.dirs && child.dirs[0]) {
const value = child.dirs[0].value;
const oldValue = child.dirs[0].oldValue;
if (!value && value !== oldValue) {
nextTick(() => {
if (attrs.onAfterLeave) {
(attrs as any).onAfterLeave(instance.vnode.el);
}
});
}
}
});
return () => {
return slots.default?.();
};
},
}) as any;
TransitionGroup = defineComponent({
name: 'TransitionGroupForTest',
inheritAttrs: false,
props: ['tag', 'class'],
setup(props, { slots }) {
return () => {
const { tag: Tag, ...rest } = props;
const children = slots.default?.() || [];
if (Tag) {
return <Tag {...rest}>{children}</Tag>;
} else {
return children;
}
};
},
});
}

@nikolausliu
Copy link

3.2版本了,这个bug依然存在

@uumom
Copy link

uumom commented Jun 21, 2022

这个bug没人处理么? @laijinxian

@wanghao1991
Copy link

希望官方注意下,这是个大坑,本地环境,dev开发环境都没问题,就是test测试环境有这个bug, 害我查了大半天!!!!!我的目前是3.2版本 。 我的情况是用modal.confirm打开的弹框,无论是点击关闭,还是确定, 都会出现这个bug!!

@vueComponent vueComponent deleted a comment from wanghao1991 Jul 6, 2022
@tangjinzhou
Copy link
Member

process.env.NODE_ENV === 'test' 被占用了,可以先换个环境变量打包测试环境的包,下个版本会改掉

@q359352759
Copy link

我使用vite4就没有这问题了,使用vite3依然会出现这情况

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests