Skip to content

Commit

Permalink
Merge pull request #6449 from mozilla/inspect-fix-object-list-closed
Browse files Browse the repository at this point in the history
Deselect objects when the object sidebar is closed
  • Loading branch information
keianhzo authored Jan 23, 2024
2 parents fead7c9 + aedfafa commit bf4927c
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 bf4927c

Please sign in to comment.