diff --git a/src/components/ContractHeadPanel.js b/src/components/ContractHeadPanel.js index 9ff4616..5cbb82b 100644 --- a/src/components/ContractHeadPanel.js +++ b/src/components/ContractHeadPanel.js @@ -280,10 +280,13 @@ class ContractHeadPanel extends FormPanel { module="contract" label="dateValidFrom" required - maxDate={!!edited && !!edited.dateValidTo && edited.dateValidTo} value={!!edited && !!edited.dateValidFrom && edited.dateValidFrom} onChange={(v) => this.updateAttribute("dateValidFrom", v)} readOnly={readOnlyFields.includes("dateValidFrom") || isAmendment} + // NOTE: maxDate cannot be passed if dateValidTo does not exist. + // Passing any other falsy value will block months manipulation. + // eslint-disable-next-line react/jsx-props-no-spreading + {...(edited.dateValidTo ? { maxDate: edited.dateValidTo } : null)} /> @@ -292,12 +295,13 @@ class ContractHeadPanel extends FormPanel { module="contract" label="dateValidTo" required - minDate={ - !!edited && !!edited.dateValidFrom && edited.dateValidFrom - } value={!!edited && !!edited.dateValidTo && edited.dateValidTo} onChange={(v) => this.updateAttribute("dateValidTo", v)} readOnly={readOnlyFields.includes("dateValidTo")} + // NOTE: minDate cannot be passed if dateValidFrom does not exist. + // Passing any other falsy value will block months manipulation. + // eslint-disable-next-line react/jsx-props-no-spreading + {...(edited.dateValidFrom ? { minDate: edited.dateValidFrom } : null)} />