From aacfe297bcd11a597851b47356f70d4dd0fd05ac Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 6 Dec 2022 09:55:42 +0000 Subject: [PATCH] Debounce hiding side panel to avoid toggling visibility when cycling through records --- packages/client/src/stores/sidePanel.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/client/src/stores/sidePanel.js b/packages/client/src/stores/sidePanel.js index 327fcfae82..3b3b9f5f4d 100644 --- a/packages/client/src/stores/sidePanel.js +++ b/packages/client/src/stores/sidePanel.js @@ -11,18 +11,25 @@ export const createSidePanelStore = () => { open: $store.contentId != null, } }) + let timeout const open = id => { + clearTimeout(timeout) store.update(state => { state.contentId = id return state }) } + + // Delay closing by 50ms to avoid toggling visibility when cycling though + // records const close = () => { - store.update(state => { - state.contentId = null - return state - }) + timeout = setTimeout(() => { + store.update(state => { + state.contentId = null + return state + }) + }, 50) } return {