Skip to content

Commit f6139bc

Browse files
fix: Add debounce to toolbar reveal when dragging windows to prevent accidental activation (#1989)
* fix: debounce toolbar display after dragging a window * change naming convention for debounce to match others. (snake case) * revert changes to package.json that werent meant to be comitted * Revert "change naming convention for debounce to match others. (snake case)" This reverts commit aaedee0. * revert commit aaedee0 * use snake case for drag_release_debounce_timer
1 parent 8dafafa commit f6139bc

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/gui/src/UI/UIDesktop.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,10 +1547,30 @@ async function UIDesktop(options) {
15471547
}, hideDelay);
15481548
};
15491549

1550+
// debounce timer to prevent toolbar showing immediately after drag ends
1551+
window.drag_release_debounce_timer = null;
1552+
const DRAG_RELEASE_DEBOUNCE_MS = 300;
1553+
1554+
// track when drag operations end to enable debounce
1555+
$(document).on('dragend', function() {
1556+
window.drag_release_debounce_timer = setTimeout(() => {
1557+
window.drag_release_debounce_timer = null;
1558+
}, DRAG_RELEASE_DEBOUNCE_MS);
1559+
});
1560+
1561+
// also debounce when mouseup occurs while in drag state
1562+
$(document).on('mouseup', function() {
1563+
if (window.a_window_is_being_dragged || window.an_item_is_being_dragged) {
1564+
window.drag_release_debounce_timer = setTimeout(() => {
1565+
window.drag_release_debounce_timer = null;
1566+
}, DRAG_RELEASE_DEBOUNCE_MS);
1567+
}
1568+
});
1569+
15501570
// hovering over a hidden toolbar will show it
15511571
$(document).on('mouseenter', '.toolbar-hidden', function () {
1552-
// if a window is being dragged, don't show the toolbar
1553-
if(window.a_window_is_being_dragged)
1572+
// if a window is being dragged or currently in drag release debounce period, don't show the toolbar
1573+
if(window.a_window_is_being_dragged || window.drag_release_debounce_timer !== null)
15541574
return;
15551575

15561576
// if selectable is active , don't show the toolbar

0 commit comments

Comments
 (0)