Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Show errors in create and edit only after the user makes one #1140

Merged
merged 2 commits into from
Jan 23, 2020

Conversation

jhugman
Copy link
Contributor

@jhugman jhugman commented Jan 16, 2020

Fixes #1120

This includes a number of fixes in displaying errors during manual create, which is inherited by edit.

  • only show errors after the user has typed them
  • don't show an error until the input text has been blurred at least once.
  • don't start with an empty hostname / password with an error
  • if the user is typing http or https then don't show an error until they make a mistake
  • disable the save button even when the user has detected them
  • ensure that the hostname is minimally at least two words, separated by dots.

@jhugman jhugman requested a review from a team as a code owner January 16, 2020 15:45
Copy link
Contributor

@eliserichards eliserichards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the tests. Love the regex. Some nits re: naming that can be cleaned up 👍

Comment on lines +119 to +118
// We use a marker error for an error we don't tell the user about,
// but will cause the save button to be disabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect 👏

override val togglePasswordClicks: Observable<Unit>
get() = view!!.btnPasswordToggle.clicks().mergeWith(togglePasswordVisibility)
get() = view!!.btnPasswordToggle.clicks().mergeWith(passwordFocus.map { Unit })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@@ -55,6 +53,15 @@ open class ItemMutationFragment : BackableFragment(), ItemMutationView {
override val passwordChanged: Observable<String>
get() = view!!.inputPassword.textChanges().map { it.toString() }

override val hostnameFocus
get() = focusChanges(view!!.inputHostname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use view?.inputHostname here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same with pwd and username)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is a well established pattern.

Additionally, passing an optional to focusChanges means we get an optional back. We should fail fast here if there is a problem with the layout.xml.

view.inputPassword?.setSelection(view.inputPassword?.length() ?: 0)
}
}
open fun setupKeyboardFocus(view: View) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Edit and Create subclasses are still called. I don't understand the code enough to say if those methods can be rendered obsolete.

I've added comment to this effect.

app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
@eliserichards
Copy link
Contributor

Bitrise failure:

app/src/main/res/values/strings.xml
    ERROR: strings must be translatable at line 0, column 0 for undisplayed_credential_mutation_error

@jhugman jhugman force-pushed the jhugman/1120-show-errors-only-after-user-error branch from 0dd952a to af4eb72 Compare January 21, 2020 16:37
@jhugman jhugman dismissed eliserichards’s stale review January 21, 2020 16:37

Addressed reviewer comments.

@jhugman jhugman force-pushed the jhugman/1120-show-errors-only-after-user-error branch 2 times, most recently from d2cd427 to 58cca7d Compare January 21, 2020 17:26
@jhugman jhugman force-pushed the jhugman/1120-show-errors-only-after-user-error branch from 58cca7d to e4537a6 Compare January 22, 2020 23:14
Copy link
Contributor

@eliserichards eliserichards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏 very nice very nice

@jhugman jhugman merged commit b9b9da6 into master Jan 23, 2020
@jhugman jhugman deleted the jhugman/1120-show-errors-only-after-user-error branch January 23, 2020 13:20
@turkergoksu
Copy link

@eliserichards Also fixes #1131

@eliserichards
Copy link
Contributor

Thank you @turkergoksu! Good catch! 🔥

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[manual create] Only show inline errors after fields have been changed
3 participants