Skip to content

Commit

Permalink
Deselect objects when the object sidebar is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Jan 23, 2024
1 parent fead7c9 commit aedfafa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/react-components/room/ObjectsSidebarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -17,8 +17,13 @@ export function ObjectsSidebarContainer({ onClose, hubChannel }) {
[unfocusObject, listRef]
);

const onCloseWrapper = useCallback(() => {
deselectObject();
onClose();
}, [deselectObject, onClose]);

return (
<ObjectsSidebar objectCount={objects.length} onClose={onClose}>
<ObjectsSidebar objectCount={objects.length} onClose={onCloseWrapper}>
{objects.length > 0 ? (
<List ref={listRef}>
{objects.map(object => (
Expand Down

0 comments on commit aedfafa

Please sign in to comment.