Skip to content

Commit

Permalink
fix onboarding for context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
MariiaNebesnova committed Jul 28, 2023
1 parent 761815b commit 7dd05fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/features/locators/Locator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Locator: React.FC<Props> = ({ 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;

Expand Down
4 changes: 1 addition & 3 deletions src/features/onboarding/utils/tourSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ export const createPOSteps = (refs: Record<OnbrdStep, StepRef>) => [
];

export const addLocatorsSteps = (refs: Record<OnbrdStep, StepRef>, isCustomLocatorFlow: boolean) => {
// if (!isCustomLocatorFlow) {
// return [customLocator(refs, isCustomLocatorFlow), contextMenu(refs), addToPO(refs), saveLocators(refs)];
// }

return [
customLocator(refs, isCustomLocatorFlow),
isCustomLocatorFlow ? createCustomLocator(refs) : contextMenu(refs),
Expand Down
10 changes: 7 additions & 3 deletions src/features/onboarding/utils/useOnboardingRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,16 +14,18 @@ export const useOnBoardingRef = (
) => {
const ref = useRef<HTMLDivElement>(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;
};

0 comments on commit 7dd05fa

Please sign in to comment.