From 8fe3e2fff66a4bfa1407818e3091a107a2fa342c Mon Sep 17 00:00:00 2001 From: JohnBoulanger Date: Thu, 20 Nov 2025 13:00:04 -0500 Subject: [PATCH] fix: debounce toolbar display after dragging a window --- src/gui/src/UI/UIDesktop.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js index fabbd1cf9..02fe397dd 100644 --- a/src/gui/src/UI/UIDesktop.js +++ b/src/gui/src/UI/UIDesktop.js @@ -1547,10 +1547,30 @@ async function UIDesktop(options) { }, hideDelay); }; + // debounce timer to prevent toolbar showing immediately after drag ends + window.dragReleaseDebounceTimer = null; + const DRAG_RELEASE_DEBOUNCE_MS = 300; + + // track when drag operations end to enable debounce + $(document).on('dragend', function() { + window.dragReleaseDebounceTimer = setTimeout(() => { + window.dragReleaseDebounceTimer = null; + }, DRAG_RELEASE_DEBOUNCE_MS); + }); + + // also debounce when mouseup occurs while in drag state + $(document).on('mouseup', function() { + if (window.a_window_is_being_dragged || window.an_item_is_being_dragged) { + window.dragReleaseDebounceTimer = setTimeout(() => { + window.dragReleaseDebounceTimer = null; + }, DRAG_RELEASE_DEBOUNCE_MS); + } + }); + // hovering over a hidden toolbar will show it $(document).on('mouseenter', '.toolbar-hidden', function () { - // if a window is being dragged, don't show the toolbar - if(window.a_window_is_being_dragged) + // if a window is being dragged or currently in drag release debounce period, don't show the toolbar + if(window.a_window_is_being_dragged || window.dragReleaseDebounceTimer !== null) return; // if selectable is active , don't show the toolbar