From 0f42c7eced40af7f15e6240afa5e0554a774373f Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Tue, 12 Dec 2023 10:23:04 -0500 Subject: [PATCH] :bug: AppendTo conflict resolved for migration wave datepicker (#1613) https://issues.redhat.com/browse/MTA-1815 Signed-off-by: ibolton336 --- .../components/migration-wave-form.tsx | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/client/src/app/pages/migration-waves/components/migration-wave-form.tsx b/client/src/app/pages/migration-waves/components/migration-wave-form.tsx index c376cc396d..1c69025074 100644 --- a/client/src/app/pages/migration-waves/components/migration-wave-form.tsx +++ b/client/src/app/pages/migration-waves/components/migration-wave-form.tsx @@ -34,6 +34,7 @@ import { OptionWithValue, SimpleSelect } from "@app/components/SimpleSelect"; import { NotificationsContext } from "@app/components/NotificationsContext"; import { DEFAULT_SELECT_MAX_HEIGHT } from "@app/Constants"; import { matchItemsToRefs } from "@app/utils/model-utils"; +import { useRef } from "react"; const stakeholderGroupToOption = ( value: StakeholderGroup @@ -280,6 +281,8 @@ export const WaveForm: React.FC = ({ const stakeholderGroupsToRefs = (names: string[] | undefined | null) => matchItemsToRefs(stakeholderGroups, (i) => i.name, names); + const dateRef = useRef(null); + return (
@@ -292,28 +295,30 @@ export const WaveForm: React.FC = ({ /> - ( - { - onChange(val); - trigger("endDateStr"); // Validation of endDateStr depends on startDateStr - }} - placeholder="MM/DD/YYYY" - value={value} - dateFormat={(val) => dayjs(val).format("MM/DD/YYYY")} - dateParse={(val) => dayjs(val).toDate()} - validators={[startDateRangeValidator]} - appendTo={() => document.body} - /> - )} - /> +
+ ( + { + onChange(val); + trigger("endDateStr"); // Validation of endDateStr depends on startDateStr + }} + placeholder="MM/DD/YYYY" + value={value} + dateFormat={(val) => dayjs(val).format("MM/DD/YYYY")} + dateParse={(val) => dayjs(val).toDate()} + validators={[startDateRangeValidator]} + appendTo={() => dateRef.current || document.body} + /> + )} + /> +