Skip to content

Commit

Permalink
Fixed bug where visualizer not working after using focus more in visu…
Browse files Browse the repository at this point in the history
…aliser context menu

Summary:
I introduced this to stop the visualiser going off while the framework events modal was open. However on mouse leave fires when the context menu is open. and if you click to focus then it never refires.

Also renamed the ref to make it clearer

Reviewed By: lblasa

Differential Revision: D47550672

fbshipit-source-id: 62e108e55e5c42a37d3aebded6467ececdc458df
  • Loading branch information
Luke De Feo authored and facebook-github-bot committed Jul 21, 2023
1 parent f6dcaa2 commit 8f857dc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions desktop/plugins/public/ui-debugger/components/Visualization2D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Visualization2D: React.FC<

//this ref is to ensure the mouse has entered the visualiser, otherwise when you have overlapping modals
//the hover state / tooltips all fire
const mouseInVisualiserRef = useRef(false);
const visualizerActive = useRef(false);
useEffect(() => {
const mouseListener = throttle((ev: MouseEvent) => {
const domRect = rootNodeRef.current?.getBoundingClientRect();
Expand All @@ -52,7 +52,7 @@ export const Visualization2D: React.FC<
!domRect ||
instance.uiState.isContextMenuOpen.get() ||
!snapshotNode ||
!mouseInVisualiserRef.current
!visualizerActive.current
) {
return;
}
Expand Down Expand Up @@ -98,6 +98,14 @@ export const Visualization2D: React.FC<
instance.uiActions,
]);

useEffect(() => {
return instance.uiState.isContextMenuOpen.subscribe((value) => {
if (value === false) {
visualizerActive.current = true;
}
});
}, [instance.uiState.isContextMenuOpen]);

if (!focusState || !snapshotNode) {
return null;
}
Expand All @@ -114,10 +122,10 @@ export const Visualization2D: React.FC<
instance.uiActions.onHoverNode();
}

mouseInVisualiserRef.current = false;
visualizerActive.current = false;
}}
onMouseEnter={() => {
mouseInVisualiserRef.current = true;
visualizerActive.current = true;
}}
//this div is to ensure that the size of the visualiser doesnt change when focusings on a subtree
style={
Expand Down

0 comments on commit 8f857dc

Please sign in to comment.