From eec70f4e4521ee545f2db4b4dadf3d3a2b61222c Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Fri, 19 Apr 2024 09:50:54 +0200 Subject: [PATCH] [Fix] It is not possible to complete invalid forms anymore and clicking "Complete" also saves the form --- src/components/record/Record.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/record/Record.jsx b/src/components/record/Record.jsx index 50a8b338..ffb1b6c4 100644 --- a/src/components/record/Record.jsx +++ b/src/components/record/Record.jsx @@ -1,5 +1,5 @@ import React from "react"; -import { Button, Modal } from "react-bootstrap"; +import { Button } from "react-bootstrap"; import PropTypes from "prop-types"; import { FormattedMessage, injectIntl } from "react-intl"; import withI18n from "../../i18n/withI18n"; @@ -94,10 +94,12 @@ class Record extends React.Component { if (form) { this.validateForm(); const incompleteQuestions = this._filterQuestionsBySeverity("warning"); - this.setState({ incompleteQuestions }, () => { - if (incompleteQuestions.length > 0) { + const invalidQuestions = this._filterQuestionsBySeverity("error"); + this.setState({ incompleteQuestions, invalidQuestions }, () => { + if (incompleteQuestions.length > 0 || invalidQuestions.length > 0) { this.setState({ showModal: true }); } else { + this.props.handlers.onSave(); this.props.handlers.onComplete(); } });