diff --git a/app/client/src/components/editorComponents/WidgetComponentBoundary.tsx b/app/client/src/components/editorComponents/WidgetComponentBoundary.tsx index 922e01e079..6c5ee8271b 100644 --- a/app/client/src/components/editorComponents/WidgetComponentBoundary.tsx +++ b/app/client/src/components/editorComponents/WidgetComponentBoundary.tsx @@ -1,8 +1,10 @@ -import { WIDGET_COMPONENT_BOUNDARY_CLASS } from "constants/componentClassNameConstants"; import type { ReactNode } from "react"; -import React from "react"; +import React, { useContext } from "react"; import styled from "styled-components"; +import WalkthroughContext from "components/featureWalkthrough/walkthroughContext"; +import { WIDGET_COMPONENT_BOUNDARY_CLASS } from "constants/componentClassNameConstants"; + type Props = { children: ReactNode; widgetType: string }; const WidgetComponentBoundaryWrapper = styled.div` @@ -11,8 +13,24 @@ const WidgetComponentBoundaryWrapper = styled.div` `; function WidgetComponentBoundary(props: Props) { + const { isOpened: isWalkthroughOpened, popFeature } = + useContext(WalkthroughContext) || {}; + + const closeWalkthrough = () => { + if (isWalkthroughOpened && popFeature) { + popFeature("WIDGET_CONTAINER"); + } + }; + + const onClickHandler = () => { + closeWalkthrough(); + }; + return ( - + {props.children} ); diff --git a/app/client/src/widgets/ContainerWidget/component/index.tsx b/app/client/src/widgets/ContainerWidget/component/index.tsx index b162879d0f..a3365d2995 100644 --- a/app/client/src/widgets/ContainerWidget/component/index.tsx +++ b/app/client/src/widgets/ContainerWidget/component/index.tsx @@ -1,4 +1,3 @@ -import { useContext } from "react"; import type { MouseEventHandler, PropsWithChildren, @@ -18,7 +17,6 @@ import { useSelector } from "react-redux"; import { getCurrentAppPositioningType } from "selectors/editorSelectors"; import { AppPositioningTypes } from "reducers/entityReducers/pageListReducer"; import { MAIN_CONTAINER_WIDGET_ID } from "constants/WidgetConstants"; -import WalkthroughContext from "components/featureWalkthrough/walkthroughContext"; const StyledContainerComponent = styled.div< Omit @@ -61,8 +59,6 @@ function ContainerComponentWrapper( ) { const containerRef: RefObject = useRef(null); const appPositioningType = useSelector(getCurrentAppPositioningType); - const { isOpened: isWalkthroughOpened, popFeature } = - useContext(WalkthroughContext) || {}; useEffect(() => { if (!props.shouldScrollContents) { @@ -121,17 +117,6 @@ function ContainerComponentWrapper( [props.onClickCapture], ); - const closeWalkthrough = () => { - if (isWalkthroughOpened && popFeature) { - popFeature("WIDGET_CONTAINER"); - } - }; - - const onClickHandler = (event: any) => { - closeWalkthrough(); - if (props.onClick) props.onClick(event); - }; - return ( ) => { target && target !== currentTarget ) { + /** + * NOTE: target.__reactProps$ returns undefined in cypress, therefore the below targetReactProps will be null. + * Due to this the traversed target element's react props such as onClick will get ignored. + **/ const targetReactProps = findReactInstanceProps(target); const hasOnClickableEvent = Boolean(