nijogeorgep / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

Focus losed in a form with validateOnChange = true #546

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
When we create a form with at least 2 TextItem and when validateOnChange = 
true, there is a lost of focus.

What steps will reproduce the problem?
1. Two item have got error validation (red icon)
2. I press a key in the first TextItem, the red icon disapear immediatly 
(validateOnChange=true), but the focus has changed to the next TextItem with 
error !

What is the expected output? What do you see instead?
The focus must remain on the textItem on which you type the text.

What version of the product are you using? On what operating system?
Nightly smartgwt lpgl 2.3 (2010-12-08)

Please provide any additional information below.
Maybe, there is a link with Issue 309

Sample code :

    public void onModuleLoad() {
        Window myWindow = new Window();
        myWindow.setHeight(400);
        myWindow.setWidth(700);

        DynamicForm form = new DynamicForm();

        TextItem myTextItem1 = new TextItem();
        myTextItem1.setRequired(true);

        TextItem myTextItem2 = new TextItem();
        myTextItem2.setRequired(true);

        form.setItems(myTextItem1, myTextItem2);
        form.setValidateOnChange(true);

        myWindow.addItem(form);

        myWindow.show();

        form.validate();
    }

Original issue reported on code.google.com by xavier.b...@gmail.com on 9 Dec 2010 at 11:27

GoogleCodeExporter commented 8 years ago

Original comment by smartgwt...@gmail.com on 17 Dec 2010 at 8:55

GoogleCodeExporter commented 8 years ago
This is neither a duplicate of Issue 309 nor fixed.  I have the exact same 
problem described here and could reproduce the error with smartGWT 2.5, 3.0 and 
3.0p (from 2012-06-12).

I would kindly ask you to run this code and verify/re-open this issue again.

Original comment by glooo.de...@gmail.com on 20 Jun 2012 at 12:05

GoogleCodeExporter commented 8 years ago
Sorry, you're correct this is not a duplicate, however we're marking this 
WontFix.

What's happening here is that when a form validates, the focus goes to the 
first field that has an error.  So focus moves away from the required=true 
field after one character is typed since typing one character makes that field 
valid.

This is the expected behavior for setting validateOnChange at the form level, 
and as the docs suggest, in most cases it makes sense to set it on the item 
level instead.

Let us know if you can't get what you want from using the item-level setting.

Original comment by smartgwt...@gmail.com on 20 Jun 2012 at 6:09

GoogleCodeExporter commented 8 years ago
What I've experienced with 3.0 (haven't tried 3.0p) is that even if 
validateOnChange is set on FormItem level the focus jumps to the next invalid 
field as soon as anything valid has been entered. A bit annoying if you try to 
enter e.g. 100 and 1 is also a valid value. I've switched to validateOnExit, so 
currently this isn't a problem for me.

Original comment by avand...@gmail.com on 20 Jun 2012 at 6:32

GoogleCodeExporter commented 8 years ago
I found no difference in behavior when setting the flag on form or on form item 
level. I also triggered the validation on a form item level, with no change.

When I creates a form with free text items (i.e. text items and text areas), 
which are not supposed to be empty I cannot use the validateOnChange feature. 
It essentially breaks my GUI, because, if the empty form was validated the user 
can write exactly one character per text field, before the cursor jumps to the 
next, which I would not describe as "desired behavior".

Also I would rather not like to use the described workaround with 
validateOnExit, because it delays the feedback to the user unnecessarily.

I would like to ask you to reconsider this issue and think about an option to 
turn off the automatic focus change on a form level.
I am, of course, also happy with another workaround that makes validateOnChange 
work as desired.

Original comment by glooo.de...@gmail.com on 21 Jun 2012 at 11:33

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
We've made a change to address this in the latest nightly build (3.1d branch 
only)

Original comment by smartgwt...@gmail.com on 29 Jun 2012 at 6:57