From aedfafa13153071b7eec2b65ddfa03177de44ccb Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Tue, 23 Jan 2024 16:01:14 +0100 Subject: [PATCH] Deselect objects when the object sidebar is closed --- src/react-components/room/ObjectsSidebarContainer.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/react-components/room/ObjectsSidebarContainer.js b/src/react-components/room/ObjectsSidebarContainer.js index 4f69ee2eda..a404d27793 100644 --- a/src/react-components/room/ObjectsSidebarContainer.js +++ b/src/react-components/room/ObjectsSidebarContainer.js @@ -6,7 +6,7 @@ import { useObjectList } from "./hooks/useObjectList"; export function ObjectsSidebarContainer({ onClose, hubChannel }) { const listRef = useRef(); - const { objects, selectedObject, selectObject, unfocusObject, focusObject } = useObjectList(); + const { objects, selectedObject, selectObject, deselectObject, unfocusObject, focusObject } = useObjectList(); const onUnfocusListItem = useCallback( e => { @@ -17,8 +17,13 @@ export function ObjectsSidebarContainer({ onClose, hubChannel }) { [unfocusObject, listRef] ); + const onCloseWrapper = useCallback(() => { + deselectObject(); + onClose(); + }, [deselectObject, onClose]); + return ( - + {objects.length > 0 ? ( {objects.map(object => (