mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 11:17:46 +08:00
fix(hooks): [useLockscreen] close shake (#9610)
* fix(hooks): [useLockscreen] close shake * fix(hooks): [useLockscreen] remove unused * fix(hooks): [useLockscreen] unit test
This commit is contained in:
parent
adc468cb50
commit
fda97e27dd
@ -29,7 +29,10 @@ describe('useLockscreen', () => {
|
||||
|
||||
wrapper.unmount()
|
||||
await nextTick()
|
||||
expect(hasClass(document.body, kls)).toBe(false)
|
||||
|
||||
setTimeout(() => {
|
||||
expect(hasClass(document.body, kls)).toBe(false)
|
||||
}, 250)
|
||||
})
|
||||
|
||||
it('should cleanup when unmounted', async () => {
|
||||
@ -45,6 +48,8 @@ describe('useLockscreen', () => {
|
||||
shouldRender.value = false
|
||||
await nextTick()
|
||||
|
||||
expect(hasClass(document.body, kls)).toBe(false)
|
||||
setTimeout(() => {
|
||||
expect(hasClass(document.body, kls)).toBe(false)
|
||||
}, 250)
|
||||
})
|
||||
})
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { isRef, onScopeDispose, watch } from 'vue'
|
||||
|
||||
import { computed } from '@vue/reactivity'
|
||||
import { isClient } from '@vueuse/core'
|
||||
import {
|
||||
@ -40,10 +39,12 @@ export const useLockscreen = (trigger: Ref<boolean>) => {
|
||||
let bodyWidth = '0'
|
||||
|
||||
const cleanup = () => {
|
||||
removeClass(document.body, hiddenCls.value)
|
||||
if (withoutHiddenClass) {
|
||||
document.body.style.width = bodyWidth
|
||||
}
|
||||
setTimeout(() => {
|
||||
removeClass(document.body, hiddenCls.value)
|
||||
if (withoutHiddenClass) {
|
||||
document.body.style.width = bodyWidth
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
watch(trigger, (val) => {
|
||||
if (!val) {
|
||||
|
Loading…
Reference in New Issue
Block a user