diff --git a/src/features/locators/Locator.tsx b/src/features/locators/Locator.tsx index 5bd446cf..65b07ab5 100644 --- a/src/features/locators/Locator.tsx +++ b/src/features/locators/Locator.tsx @@ -52,7 +52,7 @@ export const Locator: React.FC = ({ element, currentPage, searchState, de const dispatch = useDispatch(); const [isEditModalOpen, setIsEditModalOpen] = useState(false); - const { isOpen: isCustomLocatorFlow } = useContext(OnboardingContext); + const { isCustomLocatorFlow } = useContext(OnboardingContext); const { element_id, type, name, locator, generate, message, deleted, active, isCustomLocator } = element; diff --git a/src/features/onboarding/utils/tourSteps.tsx b/src/features/onboarding/utils/tourSteps.tsx index eb2d428c..a9940130 100644 --- a/src/features/onboarding/utils/tourSteps.tsx +++ b/src/features/onboarding/utils/tourSteps.tsx @@ -176,9 +176,7 @@ export const createPOSteps = (refs: Record) => [ ]; export const addLocatorsSteps = (refs: Record, isCustomLocatorFlow: boolean) => { - // if (!isCustomLocatorFlow) { - // return [customLocator(refs, isCustomLocatorFlow), contextMenu(refs), addToPO(refs), saveLocators(refs)]; - // } + return [ customLocator(refs, isCustomLocatorFlow), isCustomLocatorFlow ? createCustomLocator(refs) : contextMenu(refs), diff --git a/src/features/onboarding/utils/useOnboardingRef.ts b/src/features/onboarding/utils/useOnboardingRef.ts index cc9a45b1..b9f3e65d 100644 --- a/src/features/onboarding/utils/useOnboardingRef.ts +++ b/src/features/onboarding/utils/useOnboardingRef.ts @@ -4,6 +4,8 @@ import { OnbrdStep } from "../types/constants"; import { useSelector } from "react-redux"; import { selectFirstLocatorByPO } from "../../locators/selectors/locatorsByPO.selectors"; +const locatorPageSteps = [OnbrdStep.CustomLocator, OnbrdStep.EditLocator, OnbrdStep.AddToPO, OnbrdStep.SaveLocators]; + export const useOnBoardingRef = ( refName: OnbrdStep, onClickNext?: (...args: any) => void, @@ -12,16 +14,18 @@ export const useOnBoardingRef = ( ) => { const ref = useRef(null); - const { addRef, isCustomLocatorFlow } = useContext(OnboardingContext); + const { addRef, isCustomLocatorFlow, isOpen } = useContext(OnboardingContext); const isFirstLocatorChecked = useSelector(selectFirstLocatorByPO)?.generate; + /* if unboarding is closed, no need to save these refs */ + const isRedundantStep = !isOpen && locatorPageSteps.includes(refName); useLayoutEffect(() => { const _ref = refName === OnbrdStep.EditLocator && isCustomLocatorFlow && ref.current ? { current: ref.current.closest(".ant-modal-content") } : ref; - !isSkipHook && addRef(refName, _ref, onClickNext, onClickPrev); + (!isSkipHook && !isRedundantStep) && addRef(refName, _ref, onClickNext, onClickPrev); }, [ref, isFirstLocatorChecked]); - return !isSkipHook ? ref : null; + return (!isSkipHook && !isRedundantStep) ? ref : null; };