-
Notifications
You must be signed in to change notification settings - Fork 206
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
bug(number-field): update number-field value on pressing "enter" #3638
Conversation
Tachometer resultsChromenumber-field permalink
slider permalink
Firefoxnumber-field permalink
slider permalink
|
2360ef8
to
5a426e4
Compare
@TarunAdobe some VRTs are failing. Can you look at them |
7808521
to
bc7ffca
Compare
@@ -340,6 +340,13 @@ export class NumberField extends TextfieldBase { | |||
new Event('change', { bubbles: true, composed: true }) | |||
); | |||
break; | |||
case 'Enter': | |||
event.preventDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the default that you're preventing here?
We haven't gotten to Form Association for these Custom Elements, but in the future, were this associated to a form, there would be some expectation that Enter
would submit the form by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point! I have removed the event.preventDefault()
and I've updated the few tests with the current behaviour expectations
this.inputElement.value = this.formattedValue; | ||
this.dispatchEvent( | ||
new Event('change', { bubbles: true, composed: true }) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good are there any tests that would be beneficial to add in support of this going forward?
1f861d7
to
de0544f
Compare
20c79f0
to
61aa8cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like what you've settled on here! A couple of extra cases to confirm and tests to duplicate before we can merge this, but it's really starting to shape up.
@@ -400,7 +405,11 @@ export class NumberField extends TextfieldBase { | |||
} | |||
} | |||
this.value = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line will trigger the setter. Will the following lines never accidentally dispatch a second change
event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no because in the setter we are updated the lastCommittedValue which will cause the check on the line 409 to fail making sure there is not second change
event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to go. I'm gonna rebase this to main
and make sure CI is still happy before merging.
One thing to keep an eye on, the tests that you touched were a tiny bit flaky before and this may increase the negative effect of that flakiness in future work. If we see a jump in transient failures, let's make time in a team sync to discuss ways to make these tests more stable.
65bc5ae
to
0e21010
Compare
Description
If you type in a number larger than the max attribute and press "return", it should change the number to the max.
i.e. The value inside the number-field should update on pressing "return" however right now it only happens when the input is blurred out.
Related issue(s)
Motivation and context
If you type in a number larger than the max attribute and press "return", it doesn't always change the number. However, the number is always changed when the input is blurred. In addition, the number is never changed when format-options is used, and the number is only changed the first time you press "return" even without format-options.
How has this been tested?
Screenshots (if appropriate)
Types of changes
Checklist
Best practices
This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against
main
.