fix: prevent modal from closing when text selection extends beyond dialog boundary
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<Transition name="modal">
|
<Transition name="modal">
|
||||||
<div v-if="dialogVisible" class="model-editor-overlay" @click.self="handleCancel">
|
<div v-if="dialogVisible" class="model-editor-overlay" @mousedown.self="handleOverlayMouseDown" @mouseup.self="handleOverlayMouseUp">
|
||||||
<div class="model-editor-modal">
|
<div class="model-editor-modal">
|
||||||
<!-- 关闭按钮 -->
|
<!-- 关闭按钮 -->
|
||||||
<button class="close-btn" @click="handleCancel" :aria-label="$t('common.close')">
|
<button class="close-btn" @click="handleCancel" :aria-label="$t('common.close')">
|
||||||
@@ -992,6 +992,19 @@ watch(() => formData.value.modelName, () => {
|
|||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 遮罩层点击关闭:只有 mousedown 和 mouseup 都发生在遮罩层上才关闭,
|
||||||
|
// 防止在输入框中拖选文字时鼠标滑出弹窗导致误关闭
|
||||||
|
let overlayMouseDownFired = false
|
||||||
|
const handleOverlayMouseDown = () => {
|
||||||
|
overlayMouseDownFired = true
|
||||||
|
}
|
||||||
|
const handleOverlayMouseUp = () => {
|
||||||
|
if (overlayMouseDownFired) {
|
||||||
|
handleCancel()
|
||||||
|
}
|
||||||
|
overlayMouseDownFired = false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user