diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/RequiredQuestionTest.kt b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/RequiredQuestionTest.kt index f6de4d0eb05..59ef9ddda7b 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/RequiredQuestionTest.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/RequiredQuestionTest.kt @@ -8,6 +8,7 @@ import org.junit.Test import org.junit.rules.RuleChain import org.junit.runner.RunWith import org.odk.collect.android.support.StorageUtils.getAuditLogForFirstInstance +import org.odk.collect.android.support.pages.FormEntryPage import org.odk.collect.android.support.rules.CollectTestRule import org.odk.collect.android.support.rules.TestRuleChain.chain import org.odk.collect.strings.R @@ -44,6 +45,16 @@ class RequiredQuestionTest { .swipeToNextQuestionWithConstraintViolation("Custom message") } + @Test + fun errorMessageDisappearsAfterActivityRecreation() { + rule.startAtMainMenu() + .copyForm("required_question_with_custom_error_message.xml") + .startBlankForm("required_question_with_custom_error_message") + .swipeToNextQuestionWithConstraintViolation("Custom message") + .rotateToLandscape(FormEntryPage("required_question_with_custom_error_message")) + .assertTextDoesNotExist("Custom message") + } + @Test fun validatingFormByPressingValidateInOptionsMenuOnSameScreen_usesNewlyAddedAnswers() { rule.startAtMainMenu() diff --git a/collect_app/src/main/java/org/odk/collect/android/views/WidgetAnswerText.kt b/collect_app/src/main/java/org/odk/collect/android/views/WidgetAnswerText.kt index e43a8bc9c04..0663ec40fd2 100644 --- a/collect_app/src/main/java/org/odk/collect/android/views/WidgetAnswerText.kt +++ b/collect_app/src/main/java/org/odk/collect/android/views/WidgetAnswerText.kt @@ -63,6 +63,7 @@ class WidgetAnswerText(context: Context, attrs: AttributeSet?) : FrameLayout(con binding.editText.transformationMethod = PasswordTransformationMethod.getInstance() binding.textView.transformationMethod = PasswordTransformationMethod.getInstance() } + setError(null) } fun updateState(readOnly: Boolean) { @@ -166,7 +167,9 @@ class WidgetAnswerText(context: Context, attrs: AttributeSet?) : FrameLayout(con } fun setError(error: String?) { - binding.textInputLayout.error = error + binding.textInputLayout.post { + binding.textInputLayout.error = error + } } fun setFocus(focus: Boolean) {