diff --git a/form/src/main/java/org/dhis2/form/ui/FormView.kt b/form/src/main/java/org/dhis2/form/ui/FormView.kt index 83388f2477..168992af15 100644 --- a/form/src/main/java/org/dhis2/form/ui/FormView.kt +++ b/form/src/main/java/org/dhis2/form/ui/FormView.kt @@ -75,7 +75,6 @@ import org.dhis2.ui.ErrorFieldList import org.dhis2.ui.dialogs.bottomsheet.BottomSheetDialog import org.dhis2.ui.dialogs.bottomsheet.BottomSheetDialogUiModel import org.dhis2.ui.dialogs.bottomsheet.FieldWithIssue -import org.dhis2.ui.dialogs.bottomsheet.IssueType import org.hisp.dhis.android.core.arch.helpers.FileResourceDirectoryHelper import org.hisp.dhis.android.core.common.ValueType import org.hisp.dhis.android.core.common.ValueTypeRenderingType @@ -467,9 +466,7 @@ class FormView : Fragment() { isEventCompleted: Boolean, bottomSheetDialog: BottomSheetDialog, ) { - val errorsInField = - fieldsWithIssues.isNotEmpty() || fieldsWithIssues.any { it.issueType == IssueType.ERROR } - if (errorsInField) { + if (fieldsWithIssues.any { it.issueType.shouldShowError() }) { bottomSheetDialog.dismiss() } else if (isEventCompleted) { onFinishDataEntry?.invoke() diff --git a/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt b/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt index 807f43d629..30ee351719 100644 --- a/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt +++ b/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt @@ -13,4 +13,7 @@ enum class IssueType { WARNING, ERROR_ON_COMPLETE, WARNING_ON_COMPLETE, + ; + + fun shouldShowError() = this == ERROR || this == ERROR_ON_COMPLETE || this == MANDATORY }