[MGNLUI-3212] BasicTextCodeField validation kicks in on each input change Created: 22/Oct/14  Updated: 09/Mar/21  Resolved: 09/Mar/21

Status: Closed
Project: Magnolia UI
Component/s: forms
Affects Version/s: 5.3.4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Federico Grilli Assignee: Unassigned
Resolution: Workaround exists Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File validation-nuisance.png    
Issue Links:
dependency
is depended upon by MGNLGROOVY-125 Fix create/edit script quirks Closed
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
Date of First Response:

 Description   

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.



 Comments   
Comment by Roman Kovařík [ 09/Mar/21 ]

The behaviour can be specified.

Generated at Mon Feb 12 09:04:20 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.