frappe: Incorrect number format handling leads to decimal point being shifted
First I thought that for some reason or other I missed the worst part of #22392.
But unfortunately – though even harder to understand – the problem with decimal separators got substantially worse during the last few weeks.
In the case of the number format being #.###,##, I‘m just tabbing my way through the fields, back and forth. Now see what happens:
https://github.com/frappe/frappe/assets/46800703/12202aba-5c5c-43cc-a9d8-ffb6db8a29ea
What was 2.5 becomes 25, all of a sudden and without any manual input. This is horrible and needs to be fixed asap.
This is my bench:
v14 comparison
I doublechecked the error on a fresh v14 bench, and there the bug isn‘t present, except for the mere formatting issue reported in #22392:
https://github.com/frappe/frappe/assets/46800703/0e01ddfd-fe9e-414b-9269-cab242e232a2
The corresponding bench:
It would be very helpful to find out which PR may have caused the problem. Then it should be easier to tackle.
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 20 (20 by maintainers)
I will look into it, but it may take some time. Maybe this weekend? I can‘t promise.
TIL, for better debugging: https://stackoverflow.com/a/15923770
The issue (e.g.
3,500becomes3.5) is observed during this sequence:Could
<html lang="en">in./frappe/templates/base.htmlbe responsible for that? See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang?retiredLocale=de#:~:text=or the language that the editable elements should be written in by the userSidenote:
resulting in an indiscriminate
frappe.boot.lang = "en"in the following cases:while:
cypress/integration/control_float.js should catch it, see https://github.com/frappe/frappe/issues/22521#issuecomment-1733226198.
But it doesn‘t, see for example this test run here and the video.
focus()and blur() might not work properly. At least I can‘t see the field getting its:focusstyle in the step-by-step snapshots, while in the video, I can’t see the field losing its:focusstyle.However, there‘s so much going on there – reformatting the number back and forth – that it‘s really hard to see what‘s wrong, and I may not be proficient enough in JS debugging… 💁🏻♂️
During Research I found:
It looks like a more reliable implementation than the custom made frappe stuff. 🤷 Support is almost ubiquitous as of recently and there’s a polyfill for older browsers.
While the unit failure mode is clearly described, I can’t tell with 100% accuracy the side conditions to be met for an integration test to fail (although I had added an integration tes fixed by my PR). When the unit already fails, that’s a bit of a secondary concern, after all but I believe it may be reproducible at the integration level with precision set to
0on a currency(float) field.Since I could reproduce the issue described herein, I’m affected and the other investigation is still fresh, I’ll try to fix this today.
That wouldn’t be any better, true.
However I never hit that bug and didn‘t manage to reproduce on a clean v14 install. Under which circumstances does 12050 become 12 with 4d0b0d35efa64a1692e075b71ae70c4969b81cda?
I’m absolutely with you. 👍
Without cypress properly working on PRs I fear we won‘t be able to ship a stable product, though. Cypress testing should probably be fixed first.
This regression goes back to the commit 0568795.
I‘ll create a (failing) cypress testcase to get this bug covered. We can‘t simply revert @blaggacao‘s revert though, as he found (and obviously fixed) another bug with that commit. Probably it‘s wrong both ways: with and without the code, so we need better code that manages to fix both of them at once.
edit: I looked at the cypress test cases, and they should have caught this. Problem is: Cypress currently doesn‘t work at all, so tests are either skipped or the setup fails anyway.