diff --git a/src/components/forms/__tests__/selection-plan-form.test.js b/src/components/forms/__tests__/selection-plan-form.test.js index 35bce9f58..305384928 100644 --- a/src/components/forms/__tests__/selection-plan-form.test.js +++ b/src/components/forms/__tests__/selection-plan-form.test.js @@ -61,6 +61,8 @@ jest.mock("openstack-uicore-foundation/lib/utils/query-actions", () => ({ queryEventTypes: jest.fn() })); +jest.mock("../../../hooks/useScrollToError", () => jest.fn()); + jest.mock("../../mui/formik-inputs/mui-formik-datetimepicker", () => ({ __esModule: true, default: ({ name }) =>
diff --git a/src/components/forms/selection-plan-form.js b/src/components/forms/selection-plan-form.js index 416062d9e..4ba555944 100644 --- a/src/components/forms/selection-plan-form.js +++ b/src/components/forms/selection-plan-form.js @@ -20,7 +20,7 @@ import { epochToMomentTimeZone } from "openstack-uicore-foundation/lib/utils/met import Box from "@mui/material/Box"; import Tab from "@mui/material/Tab"; import Tabs from "@mui/material/Tabs"; -import { scrollToError } from "../../utils/methods"; +import useScrollToError from "../../hooks/useScrollToError"; import MainTab from "./selection-plan-form/main-tab"; import TrackGroupsTab from "./selection-plan-form/track-groups-tab"; import EventTypesTab from "./selection-plan-form/event-types-tab"; @@ -111,12 +111,13 @@ const SelectionPlanForm = (props) => { }); useEffect(() => { - scrollToError(propsErrors); formik.setErrors( propsErrors && Object.keys(propsErrors).length > 0 ? propsErrors : {} ); }, [propsErrors]); + useScrollToError(formik, true, setActiveTab); + // Sync sub-resource arrays from Redux without resetting user-editable main tab fields useEffect(() => { formik.setValues((current) => ({ diff --git a/src/components/forms/selection-plan-form/email-templates-tab.js b/src/components/forms/selection-plan-form/email-templates-tab.js index c822f0bbe..62a7e67d3 100644 --- a/src/components/forms/selection-plan-form/email-templates-tab.js +++ b/src/components/forms/selection-plan-form/email-templates-tab.js @@ -37,6 +37,7 @@ const EmailTemplatesTab = ({ hidden }) => {