Chrome drag/drop bug: skip DOM update on dragenter

On Chromium, if the DOM is updated during a dragenter event (e.g. to
display the drop zone div), the browser will immediately fire dragleave
as well which leads to a rapid flickering effect.
This commit is contained in:
Noah 2025-03-27 22:21:00 -07:00
parent e090841b03
commit 2268209998

View File

@ -3654,7 +3654,11 @@ export default {
$body.addEventListener("dragenter", (e) => {
e.preventDefault();
e.stopPropagation();
$dropArea.classList.add("is-active");
// Chrome bug: do not manipulate the DOM on drag start or it'll fire dragleave right away.
window.requestAnimationFrame(() => {
$dropArea.classList.add("is-active");
});
});
$body.addEventListener("dragover", (e) => {
e.preventDefault();