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

BasicTextCodeField validation kicks in on each input change

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Workaround exists
    • Icon: Major Major
    • None
    • 5.3.4
    • forms
    • None

      I created a GroovyValidator which checks for the formal source code correctness upon saving a Groovy script. The validator is attached to a basic text code field. If I start writing invalid Groovy code the validator does not complain and that's fine, because ideally that should happen only upon saving the form. Once I save the form the validator rightly complains and shows an error. The annoying thing now is that trying to fix the code will trigger validation for each input change thus cluttering the UI with error messages. See attached screenshot.

      After further debugging I actually found out that validation is triggered at each StateChangeEvent fired by the field which currently has the focus (see com.vaadin.ui.AbstractField.getErrorMessage() at line 1034 where the condition is true by default). The only reason validation errors are not displayed immediately but only upon saving a form is found at info.magnolia.ui.vaadin.form.FormSection.getErrorMessage() line #109. That state variable is false until a SaveAction e.g. info.magnolia.ui.form.action.SaveFormAction changes its value at line #87. From then on validation errors are shown in "real-time".
      I guess, it would be cool to have greater control over how we display errors on the UI or have a sensible default strategy, e.g. no validation performed automatically but only on submitting a form. In case of errors, validation is disabled until the next form submission. Just my zwei Rappen.

        Acceptance criteria

              Unassigned Unassigned
              fgrilli Federico Grilli
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD