Skip to content

Commit 16cc37f

Browse files
chiragsalianOSBotify
authored andcommitted
Merge pull request #48109 from cretadn22/handle-same-value-submit
[CP Staging] Update submit function in initial report field value (cherry picked from commit 5368e47) (CP triggered by chiragsalian)
1 parent 9af65b2 commit 16cc37f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,21 @@ function ReportFieldsInitialValuePage({
4343
const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
4444
const reportField = policy?.fieldList?.[ReportUtils.getReportFieldKey(reportFieldID)] ?? null;
4545
const availableListValuesLength = (reportField?.disabledOptions ?? []).filter((disabledListValue) => !disabledListValue).length;
46-
47-
const [initialValue, setInitialValue] = useState(WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField));
46+
const currentInitialValue = WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField);
47+
const [initialValue, setInitialValue] = useState(currentInitialValue);
4848

4949
const submitForm = useCallback(
5050
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_REPORT_FIELDS_FORM>) => {
51-
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === values.initialValue ? '' : values.initialValue);
51+
if (currentInitialValue !== values.initialValue) {
52+
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, values.initialValue);
53+
}
5254
Navigation.goBack();
5355
},
54-
[policyID, reportFieldID, initialValue],
56+
[policyID, reportFieldID, currentInitialValue],
5557
);
5658

5759
const submitListValueUpdate = (value: string) => {
58-
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === value ? '' : value);
60+
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, currentInitialValue === value ? '' : value);
5961
Navigation.goBack();
6062
};
6163

0 commit comments

Comments
 (0)