From ca66584c4df5fefb52e8fd931383ce444f70ec51 Mon Sep 17 00:00:00 2001 From: olewandowski1 Date: Thu, 8 Feb 2024 14:37:14 +0100 Subject: [PATCH] OP-1806: fix calendar picker to allow selecting future dates --- src/components/ContractHeadPanel.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/ContractHeadPanel.js b/src/components/ContractHeadPanel.js index 9ff4616..9f12f9e 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 endDate 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 startDate 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)} />