Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo MoneyInput (better UX, less error cases) #175

Merged
merged 4 commits into from
Oct 23, 2018

Conversation

dferber90
Copy link
Contributor

@dferber90 dferber90 commented Oct 18, 2018

The old MoneyInput was capable of displaying an error either on the currency dropdown or the amount input:

hasCurrencyError hasAmountError
image image

After talking to @filippobocik we agreed to drop the individual error states from MoneyInput. MoneyInput will now only accept hasError (and hasWarning) instead of hasCurrencyError and hasAmountError.

<MoneyInput
- hasAmountError={true}
- hasCurrencyError={true}
- hasAmountWarning={true}
- hasCurrencyWarning={true}
+ hasError={true}
+ hasWarning={true}
/>

This makes the code easier for consumers as they only need to worry about one error state and they don't need to worry about individual touched states anymore to display the errors in the right cases.

Old MoneyInput in a form

money-old

  • Notice how the error appears while the user is still interacting with the MoneyInput. It pops up before the user has a chance to type the amount.

New MoneyInput in a form

money-new

  • The error only appears when the user leaves the MoneyInput completely
  • The amount-input gets focused automatically after selecting a currency to improve UX

Play with it https://deploy-preview-175--mc-uikit.netlify.com/?selectedKind=Examples%7CForms%2FInputs&selectedStory=MoneyInput&full=0&addons=1&stories=1&panelRight=1&addonPanel=storybook%2Factions%2Factions-panel.

@dferber90
Copy link
Contributor Author

dferber90 commented Oct 18, 2018

Tests are failing. I'll rewrite them with react-testing-library and ping ya'll again once it's ready for dev review. UX review can continue.

@dferber90
Copy link
Contributor Author

Note to self: MoneyField supports errors.missing, as do all fields. But there is a difference between a missing value and an incomplete value. A missing-value-error only happens for required fields, while a incomplete-value-error can happen for optional fields (e.g. when an amount is provided, but no currency).

We should add errors.incomplete to MoneyField and handle that. Maybe also MoneyField.isIncomplete to determine such cases.

@dferber90 dferber90 force-pushed the df-redo-money-input-error-props branch from 7e79a55 to 3e9aee8 Compare October 18, 2018 18:41
@dferber90
Copy link
Contributor Author

New tests with react-testing-library are up!

I skipped converting the tests related to styling as testing classnames doesn't seem like the right way for this anyways.

Copy link
Contributor

@tdeekens tdeekens left a comment

Choose a reason for hiding this comment

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

The UX simplification is real nice. Maybe there is one mistake in the docs. Not sure.

BREAKING CHANGE: dropped support for hasAmountError, hasAmountWarning, hasCurrencyError and hasCurrencyWarning. Use hasError and hasWarning instead.

BREAKING CHANGE: isTouched only returns true when both fields were touched from now on.
… focus

We only mark both as blurred when an element which is not part of the MoneyInput gains focus. This is done to ensure the MoneyInput acts as one unit so that errors can be displayed correctly (as they rely on both touched states and would pop up too early if only one of them is checked).

This also auto-focuses the amount intput after a currency has been selected.
@dferber90 dferber90 force-pushed the df-redo-money-input-error-props branch from c9b6b32 to e1c2025 Compare October 22, 2018 13:05
@dferber90 dferber90 removed the request for review from lufego October 22, 2018 13:08
@dferber90 dferber90 merged commit 9e00148 into master Oct 23, 2018
@dferber90 dferber90 deleted the df-redo-money-input-error-props branch October 24, 2018 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👨‍🎨 Status: UI/UX Review Requires review from design team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants