-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
fix(hooks): [use-lockscreen] removing class name at wrong time #16389
base: dev
Are you sure you want to change the base?
Conversation
👋 @JauSingSing, seems like this is your first time contribution to element-plus.
|
Hello @JauSingSing, thank you for contributing to element-plus, please see our guideline to see how to make contribution |
🧪 Playground Preview: https://element-plus.run/?pr=16389 |
9558010
to
f740ad8
Compare
@btea Hi, I messed up the commit before :( , it looks more normal now. Please review it in your free time, thx. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
这个代码还是有点问题,当第一个弹框关闭的同时第二个弹框出现,第一个弹框 withoutHiddenClass 是 true,会 remove 掉 class,这是错的,请看下面用例 @btea @JauSingSing it('should not remove class name when another trigger sync true', async () => {
await sleep(250)
const trigger = mount({
setup: () => () => <Comp />,
})
await nextTick()
expect(hasClass(document.body, kls)).toBe(true)
trigger.unmount()
// Trigger is close and anotherTrigger is open
const anotherTrigger = mount({
setup: () => () => <Comp />,
})
await nextTick()
await sleep(250)
expect(hasClass(document.body, kls)).toBe(true)
}) |
@JauSingSing @btea ![]() 然后新增一个判断函数 export const hasClassPrefix = (el: Element, cls: string): boolean => {
if (!el || !cls) return false
if (cls.includes(' ')) throw new Error('className should not contain space.')
for (const className of el.classList) {
if (className.startsWith(cls)) {
return true
}
}
return false
} ![]() |
fix(hooks): [use-lockscreen] removing class name at wrong time