Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 AppendTo conflict resolved for migration wave datepicker #1613

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -280,6 +281,8 @@ export const WaveForm: React.FC<WaveFormProps> = ({
const stakeholderGroupsToRefs = (names: string[] | undefined | null) =>
matchItemsToRefs(stakeholderGroups, (i) => i.name, names);

const dateRef = useRef<HTMLDivElement | null>(null);

return (
<Form onSubmit={handleSubmit(onSubmit)}>
<Grid hasGutter>
Expand All @@ -292,28 +295,30 @@ export const WaveForm: React.FC<WaveFormProps> = ({
/>
</GridItem>
<GridItem span={3}>
<HookFormPFGroupController
control={control}
name="startDateStr"
label="Potential Start Date"
fieldId="startDateStr"
isRequired
renderInput={({ field: { value, name, onChange } }) => (
<DatePicker
aria-label={name}
onChange={(e, val) => {
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}
/>
)}
/>
<div ref={dateRef}>
<HookFormPFGroupController
control={control}
name="startDateStr"
label="Potential Start Date"
fieldId="startDateStr"
isRequired
renderInput={({ field: { value, name, onChange } }) => (
<DatePicker
aria-label={name}
onChange={(e, val) => {
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}
/>
)}
/>
</div>
</GridItem>
<GridItem
span={1}
Expand Down