From fd4e2a4f4b2cb9f1d116d2729cd6c69c044029fa Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sun, 7 May 2023 02:34:38 +0700 Subject: [PATCH] Fix dragging when navigator is docked (#1586) Fixed conditional rendering of tree preview. ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio-builder/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env.example` and the `builder/env-check.js` if mandatory Co-authored-by: Oleg Isonen --- .../app/builder/features/inspector/inspector.tsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/builder/app/builder/features/inspector/inspector.tsx b/apps/builder/app/builder/features/inspector/inspector.tsx index 0065d0ae81..1dd4323b42 100644 --- a/apps/builder/app/builder/features/inspector/inspector.tsx +++ b/apps/builder/app/builder/features/inspector/inspector.tsx @@ -36,18 +36,10 @@ const contentStyle = { overflow: "auto", }; -// separate component to avoid inspetor updates on drag when navigator is undocked -const NavigatorTreePreview = () => { - const [dragAndDropState] = useDragAndDropState(); - if (dragAndDropState.isDragging) { - return ; - } - return null; -}; - export const Inspector = ({ publish, navigatorLayout }: InspectorProps) => { const selectedInstance = useStore(selectedInstanceStore); const tabsRef = useRef(null); + const [dragAndDropState] = useDragAndDropState(); const [tab, setTab] = useState("style"); @@ -59,8 +51,8 @@ export const Inspector = ({ publish, navigatorLayout }: InspectorProps) => { } }, [selectedInstance, tab]); - if (navigatorLayout === "docked") { - return ; + if (navigatorLayout === "docked" && dragAndDropState.isDragging) { + return ; } if (selectedInstance === undefined) {