[MGNLUI-3965] Text fields with number types don't honor user's locale Created: 28/Jul/16 Updated: 15/Mar/21 Resolved: 15/Mar/21 |
|
| Status: | Closed |
| Project: | Magnolia UI |
| Component/s: | forms |
| Affects Version/s: | 5.4.7 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Mikaël Geljić | Assignee: | Unassigned |
| Resolution: | Outdated | Votes: | 0 |
| Labels: | forms, localization, numbers | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||
| Description |
|
This was revealed by running UI tests on a local+VM setup (french), more precisely SimpleFieldUITest#setTextFieldValue.
First half of the problem is that UI tests try to get a locale-formatted number from where the test is executed (not where the driver is running, or even better from the user's preferred locale); but second half of the problem is that TextFields (and actually all fields in general) don't get their locale set properly. Something like this code block (± getting that locale from user prefs) should do the trick in TextFieldFactory: Page currentPage = Page.getCurrent(); if (Number.class.isAssignableFrom(getFieldType()) && currentPage != null) { Locale currentLocale = currentPage.getWebBrowser().getLocale(); if (currentLocale != null) { field.setLocale(currentLocale); } } ... if only the AbstractFieldFactory was not resetting every field's locale with the locale of the content being edited. There is at least some confusion there. |