Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-3965

Text fields with number types don't honor user's locale

    XMLWordPrintable

Details

    • Bug
    • Resolution: Outdated
    • Neutral
    • None
    • 5.4.7
    • forms

    Description

      This was revealed by running UI tests on a local+VM setup (french), more precisely SimpleFieldUITest#setTextFieldValue.

      1. Given double value is 10.22
      2. UI test (running on french machine) tries to fill input with "10,22" (commas stand for decimal in french format)
      3. Value change immediately parses that "1,022" (commas stand for thousands in english format, here it simply doesn't expect the comma here)

      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.

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                mgeljic Mikaël Geljić
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD