fix(modal): fix last modal not disappear (#2021)

This commit is contained in:
申君健 2024-08-31 17:58:11 +08:00 committed by GitHub
parent 77969c4b1c
commit 9fb965d3e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View File

@ -38,8 +38,6 @@ import type {
const DragClass = 'is__drag'
let timer: number
const emitZoom = ({ params, parent, emit, event }: IModalEmitZoomParam): void => {
let { $listeners, events = {} } = parent
if ($listeners.zoom) {
@ -156,16 +154,16 @@ export const selfClickEvent =
}
}
export const mouseEnterEvent = () => (): void => {
clearTimeout(timer)
export const mouseEnterEvent = (state) => (): void => {
clearTimeout(state.timer)
}
export const mouseLeaveEvent =
({ api, props }: Pick<IModalRenderlessParams, 'api' | 'props'>) =>
({ api, props, state }: Pick<IModalRenderlessParams, 'api' | 'props' | 'state'>) =>
(): void => {
api.addMsgQueue()
timer = window.setTimeout(
state.timer = window.setTimeout(
() => {
api.close('close')
},
@ -269,7 +267,7 @@ export const open =
if (state.isMsg) {
api.addMsgQueue()
timer = window.setTimeout(
state.timer = window.setTimeout(
() => {
api.close(params.type)
},

View File

@ -87,7 +87,8 @@ export const renderless = (
prevEvent: null,
options: [],
theme: props.tiny_theme,
boxStyle: computed(() => api.computedBoxStyle())
boxStyle: computed(() => api.computedBoxStyle()),
timer: 0
})
Object.assign(api, {
@ -101,8 +102,8 @@ export const renderless = (
mounted: mounted({ api, parent, props, isMobileFirstMode, state }),
beforeUnmouted: beforeUnmouted({ api, parent, isMobileFirstMode }),
selfClickEvent: selfClickEvent({ api, parent, props }),
mouseEnterEvent: mouseEnterEvent(),
mouseLeaveEvent: mouseLeaveEvent({ api, props }),
mouseEnterEvent: mouseEnterEvent(state),
mouseLeaveEvent: mouseLeaveEvent({ api, props, state }),
updateZindex: updateZindex({ state, props }),
handleEvent: handleEvent({ api, emit, parent, props, isMobileFirstMode }),
closeEvent: closeEvent(api),