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

Improve UX of numeric input #1029

Merged
merged 1 commit into from
Jul 26, 2023
Merged

Improve UX of numeric input #1029

merged 1 commit into from
Jul 26, 2023

Conversation

axelboc
Copy link
Collaborator

@axelboc axelboc commented Jul 25, 2023

On top of #1028

I'm replacing the old, buggy react-numeric-input package with the more recent rc-input-number. This brings a bunch of UX improvements out of the box, notably the fact that the precision is no longer applied while typing but on blur (i.e. when the field loses focus). This means decimals can now be removed completely with backspace, which is a lot less confusing.

I've refactored more things under the hood, but there are two additional UX changes worth mentioning:

  • I'm removing the X button in idle/ready state, which allowed closing the overlay. In busy state, this same X button is red and used to cancel the change of value. There's a conflict of purpose: the same button does two completely different things depending on the state. Moreover other overlays across the UI do not have close buttons, and there are already three ways to close the popinput overlays: by clicking on the trigger, by clicking anywhere else outside of the overlay, and by pressing Escape — I think that's plenty.
  • When busy, instead of hiding the field and showing a spinner, I now simply disable the input. This has the advantage of keeping the cancel button at the same place as the submit button, so there's no need to move the mouse to quickly cancel a change of value.

Peek 2023-07-25 11-41

@axelboc axelboc force-pushed the ab-num-input branch 2 times, most recently from bdd8bc0 to 0acb42b Compare July 25, 2023 12:31
inputSize="5"
immediate
onSave={this.props.saveStep}
{this.props.saveStep &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unrelated change: just a quick fix of the appearance of the cancel button on motor inputs. The button was previously displayed inside the step value div, which didn't look quite right. The button now replaces the entire step value div while busy:

Peek 2023-07-25 11-57

this.handleSubmit = this.handleSubmit.bind(this);
this.inputRef = React.createRef();
}
function NumericInput(props) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Converting to a function component, since it's so simple.

@@ -116,3 +116,100 @@ input[type='color']:focus,
.nowrap-style {
white-space: nowrap;
}

.rc-input-number {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried importing rc-input-number's default styles but it required a lot of overrides to make it look the way I wanted, so instead I decided to duplicate the styles and tweak them to my liking. It's not a lot of styles overall, so I think this is more maintainable that the former solution.

Base automatically changed from ab-clean-popinput to develop July 26, 2023 08:09
@marcus-oscarsson
Copy link
Member

Excellent, thanks alot ! (from sunny (not really) Maubisson) ;)

@marcus-oscarsson marcus-oscarsson merged commit c76e663 into develop Jul 26, 2023
7 of 8 checks passed
@axelboc axelboc deleted the ab-num-input branch July 26, 2023 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants