Commit 550b271
fix(Dialog): prevent mask close when dragging from content to mask (#543)
* fix(Dialog): prevent mask close when dragging from content to mask
- Use event capture to track `mousedown` and `mouseup` on the wrapper
- Ensure close is only triggered when the click action fully occurs on the mask
- Fix issue where dragging from content to mask (e.g. slider or text selection) triggers unintended close
Closes ant-design/ant-design#56348
* refactor: optimize logic and reset refs based on review
* style: optimize code formatting and naming convention
* fix: prevent modal close when dragging from content to mask
- Use bubbling `onMouseDown` to track if the click originated from the mask.
- Only trigger close in `onClick` if both mousedown and click targets are the wrapper.
- Reset tracking refs when dialog becomes visible to prevent state pollution.
- Remove capture listeners to avoid potential event conflicts.
* fix(Dialog): 移除 maskClosable 条件下不必要的 onClose 存在性检查,确保拖拽行为不会意外触发对话框关闭。同时将相关测试从独立文件合并到主测试文件中以简化结构。
---------
Co-authored-by: zkt <Zhengkangtao@leadigital.cn>1 parent 9339853 commit 550b271
2 files changed
+36
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 113 | + | |
127 | 114 | | |
128 | 115 | | |
129 | 116 | | |
130 | 117 | | |
131 | 118 | | |
132 | 119 | | |
133 | | - | |
134 | | - | |
135 | | - | |
| 120 | + | |
136 | 121 | | |
137 | 122 | | |
138 | 123 | | |
139 | 124 | | |
140 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
141 | 130 | | |
142 | 131 | | |
143 | 132 | | |
| 133 | + | |
144 | 134 | | |
145 | 135 | | |
146 | 136 | | |
| |||
158 | 148 | | |
159 | 149 | | |
160 | 150 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | 151 | | |
170 | 152 | | |
171 | 153 | | |
| |||
192 | 174 | | |
193 | 175 | | |
194 | 176 | | |
| 177 | + | |
195 | 178 | | |
196 | 179 | | |
197 | 180 | | |
198 | 181 | | |
199 | 182 | | |
200 | 183 | | |
201 | | - | |
202 | | - | |
203 | 184 | | |
204 | 185 | | |
205 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
| |||
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
188 | 215 | | |
189 | 216 | | |
190 | 217 | | |
| |||
0 commit comments