From 34c4dad0aca7007eef2b95f53b0dc7419c30b1cc Mon Sep 17 00:00:00 2001 From: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Date: Thu, 16 Sep 2021 22:24:12 +0530 Subject: [PATCH] fix: flashElement scrolls canvas too much. (#7547) --- .../Explorer/Widgets/useNavigateToWidget.ts | 4 +- app/client/src/utils/helpers.tsx | 4 +- .../ContainerWidget/component/index.tsx | 37 ++++++++++++------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/app/client/src/pages/Editor/Explorer/Widgets/useNavigateToWidget.ts b/app/client/src/pages/Editor/Explorer/Widgets/useNavigateToWidget.ts index 1f5348c118..2c547d2fe6 100644 --- a/app/client/src/pages/Editor/Explorer/Widgets/useNavigateToWidget.ts +++ b/app/client/src/pages/Editor/Explorer/Widgets/useNavigateToWidget.ts @@ -45,10 +45,12 @@ export const useNavigateToWidget = () => { selectWidget(widgetId, false); navigateToCanvas(params, window.location.pathname, pageId, widgetId); - flashElementsById(widgetId); // Navigating to a widget from query pane seems to make the property pane // appear below the entity explorer hence adding a timeout here setTimeout(() => { + if (params.pageId === pageId) { + flashElementsById(widgetId); + } dispatch(forceOpenPropertyPane(widgetId)); }, 0); }; diff --git a/app/client/src/utils/helpers.tsx b/app/client/src/utils/helpers.tsx index cd186a1077..a35804aa86 100644 --- a/app/client/src/utils/helpers.tsx +++ b/app/client/src/utils/helpers.tsx @@ -173,8 +173,8 @@ export const flashElementsById = (id: string | string[], timeout = 0) => { el?.scrollIntoView({ behavior: "smooth", - block: "nearest", - inline: "nearest", + block: "center", + inline: "center", }); if (el) flashElement(el); diff --git a/app/client/src/widgets/ContainerWidget/component/index.tsx b/app/client/src/widgets/ContainerWidget/component/index.tsx index 13d06a617e..0bd8372295 100644 --- a/app/client/src/widgets/ContainerWidget/component/index.tsx +++ b/app/client/src/widgets/ContainerWidget/component/index.tsx @@ -10,6 +10,7 @@ import WidgetStyleContainer, { } from "components/designSystems/appsmith/WidgetStyleContainer"; import { pick } from "lodash"; import { ComponentProps } from "widgets/BaseComponent"; +import { MAIN_CONTAINER_WIDGET_ID } from "constants/WidgetConstants"; const scrollContents = css` overflow-y: auto; @@ -50,10 +51,9 @@ const StyledContainerComponent = styled.div< } }`; -function ContainerComponent(props: ContainerComponentProps) { +function ContainerComponentWrapper(props: ContainerComponentProps) { const containerStyle = props.containerStyle || "card"; const containerRef: RefObject = useRef(null); - useCanvasMinHeightUpdateHook(props.widgetId, props.minHeight); useEffect(() => { if (!props.shouldScrollContents) { const supportsNativeSmoothScroll = @@ -68,6 +68,26 @@ function ContainerComponent(props: ContainerComponentProps) { } }, [props.shouldScrollContents]); return ( + + {props.children} + + ); +} + +function ContainerComponent(props: ContainerComponentProps) { + useCanvasMinHeightUpdateHook(props.widgetId, props.minHeight); + return props.widgetId === MAIN_CONTAINER_WIDGET_ID ? ( + + ) : ( - - {props.children} - + ); }