-
Notifications
You must be signed in to change notification settings - Fork 6
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
Number field revamp #2566
Number field revamp #2566
Conversation
…ent/number-field-revamp
const modifyNumberValue = (action: "increment" | "decrement") => { | ||
switch (action) { | ||
case "increment": | ||
onChange(+(+value + 1).toFixed(10), name); |
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.
we always storing 10 decimal places?
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.
I've updated how the increment/decrement works to make sure decimals are saved properly without making use of toFixed
@zcolah I have concerns with the auto comma functionality. Not only is it requiring a technical overhead with a dependency needed to be added but it brings up several questions especially in the context of a CMS. Primarily how does a user know whether the number field value is being saved with or without the commas? Also accessibility concerns:
|
> Primarily how does a user know whether the number is being saved with or without the commas? > 1. Not all regions make use of comma separators in the same way. (e.g periods are used to separate thousands and commas for decimals) > 2. Screen reader cannot read this number properly Also could you recommend a solution towards how we can make a screen reader read the number properly? |
@agalin920 I also wanted to give some key context on why the number separators (commas) are being introduced. Currently when a user inputs a larger number (e.g. 1000000000) they tend to have difficulty reading and understanding what the value is. This leads to a user potentially misreading the number or adding an extra zero or a lesser zero by mistake. See issue: #2456 |
@agalin920 @theofficialnar I also do not have full context on why the entire solution being used to achieve the commas is bad but here are some discussions I have found online that discuss how others have achieved this. Maybe they could be helpful. Let me know what I can do to unblock this issue moving forward. |
@zcolah while I understand the pain points you present I fundamentally disagree with the solution and believe the trade offs of ambiguous comma separation is worse. I agree with the html numeric input standard to not comma separate and even data entry software like sheets or excel also does not by default auto comma numbers. It makes data entry standard and in my opinion comma separation should be used for display purposes only and not data entry. Ultimately It also doesn’t follow the web standard |
For all cells that are number types, Excel adds commas and decimal places actually by default. It does not add commas for plain text (string type) cells. In fact in most calculator interfaces as well commas are added by default in the number input.
The Content App, displays to a marketer, critical number values in their content items during content creation and content review/editing. During content creation, it is important for us to display the number they are inputting in the most readable easy to scan format so as to ensure they do not make a mistake. For example it can be a question of them inputting 100,000 vs 1,000,000 for a critical page. During content review and editing, we need to make it as easy as possible for them to read a number in a number input. |
@agalin920 @theofficialnar https://codepen.io/vladracoare/pen/VwLRqRy |
@zcolah How about having some kind of preview of the number they have typed with comma separation while maintaining how the actual input already is? |
Not really looking for solution examples, even without a direct dependency they all make use of JS to manipulate the input. The main flag im raising is html number input standard deviation.
Yea suggested this as well, to maintain numeric input standard. |
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.
- @theofficialnar caught a new bug related to decimal places in VQA which did not exist before: https://www.loom.com/share/b14736392b2940ec83fc86c158895510
Sorry for the delay on the VQA for this as I was in the hospital
|
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.
Hi @theofficialnar
- A new bug has crept in since I last checked the number field. This time I cannot remove a decimal place if there is only a 0 right after it. Please see Loom for more context:
did you see this btw @theofficialnar |
Yeah, this should already be fixed with the changes yesterday |
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.
@theofficialnar
-
I cannot remove 0 if it is the last digit in the decimal places: https://www.loom.com/share/53e547912e604b93a2a12123531101e2
-
I cannot remove 0 if it is the last digit in the whole number places: https://www.loom.com/share/87cb53a9df684d37ad8533cf7ac02f5f
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.
Wrong comment. Ignore.
} | ||
}; | ||
|
||
const adjustCursorPosition = (numStr: string) => { |
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.
The complexity of this is getting very large. Is there no alternative?
Its also hard to now see the benefit of the library since its not solving much complexity
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.
I’m actually no longer using the react-number format library here hence all the complexity and bugs since I have to handle all the cursor position etc manually. I’m actually considering using the library again since it takes care of all the formatting and resolves all of the bugs @zcolah has been raising for the past couple of days. Only downside to that library being that it automatically converts the exponents to numbers with leading 0s instead of showing the actual exponent.
I am seeing that the number is being returned as an integer in the API. Looks like webengine is converting these to string in our read-only APIs. This is something we need to confirm with @jjaguilar08 |
@zcolah @agalin920 what are your thoughts on bringing back in the library which handles the number formatting etc? That library resolves all the issues that are being brought up and the complexity of this component, only issue is that it automatically converts large exponent numbers to numbers with trailing 0s instead of showing the actual exponent. |
@theofficialnar thats fine by me |
fab3d66
to
978835e
Compare
@theofficialnar fine by me as well |
@theofficialnar the Decimal places get rounded when increasing the number with the plus button. Is it possible to ensure that does not happen? https://www.loom.com/share/0f4218027df54907a55d53e73ed0ddcb?from_recorder=1&focus_title=1 |
@zcolah turns out it's a limitation with Javascript's floating-point precision hence it's getting rounded off, javascript numbers can hold 15 digits accurately |
@theofficialnar Thank you for that insight. It is fair to not resolve it but have a few follow up questions regarding the scope of this javascript constraint.
|
As of the moment, user input gets retained but the value saved on the database is rounded up.
Yes, unless they start exceeding the MAX_SAFE_INTEGER then they'll be converted to exponents
Yes |
Thank you for these insights. I am going to give it a VQA label now. |
number-field.webm