Hi,
I need help to find a solution for the issue: “blur” event happens after the value is set to the field but before it is set to the native field element, so the updateValue() method nullifies the field value.
Mostly it happens with date and text fields. We’ve observed it in Firefox (more frequently) but in IE as well.
The scenario is the following:
After some user action, we need to update a part of the page: for example, create and show new DynamicForm with different fields in an existing Layout.
We have "autoDraw" set to false, so we call show() for the form. After calling show(), we initialize fields with values by calling field.setValue(..). Note, that if call field.getValue() right after that, it returns the correct value.
Let say, first field of the form is a date field and it automatically (or sometimes randomly) receives the focus after the form is drawn.
Then we have a script running on a small timeout to reset tab indexes for all elements on the page. We have to do it every time when a part of the page is changed since the default tab index is set according to the drawing order. This script goes through all Canvas elements and its children and calls setTabIndex() for all focusable items.
Resetting tab index causes focus movement. Sometimes blur happens for the date field BEFORE the native element has the actual field value. Blur handler calls updateValue() that pulls the current native element value (which is still null) and nullifies the field value.
I set a conditional breakpoint at updateValue() in browser and I saw that at the moment of the blur event the field value is actually correct (“_value” member) and the form and fields are displayed and drawn on the page, but don’t have any values displayed yet.
Sorry, I was unable to reproduce it with an example in your feature explorer or standalone. Since it seems to be a timing issue, it is tough to provide an isolated example.
So, my questions are:
1) How we can force to propagate the field value to the native element of the text or date field? The paradox is that field is drawn already, and even has the focus, but do not have field value set for some reason.
2) Maybe there is a safer way to reset tab indexes on the page, without moving focus around? But I guess, this is just one case, blur also may happen due to other page changes or redrawing.
Increasing a timeout for the script helps a bit but does not solve the issue; even with 500ms timeout it still happens, although less frequently.
3) How can we prevent from calling blur() on the element that is not fully initialized yet? For example, can we “deactivate” somehow current focus item before resetting indexes?
-----
SmartClient : SC_SNAPSHOT-2011-02-10 (2011-02-10)
GWT: 2.1.0
We DO NOT use Smart GWT.
Browsers: IE 7&8, Firefox 3.6
I need help to find a solution for the issue: “blur” event happens after the value is set to the field but before it is set to the native field element, so the updateValue() method nullifies the field value.
Mostly it happens with date and text fields. We’ve observed it in Firefox (more frequently) but in IE as well.
The scenario is the following:
After some user action, we need to update a part of the page: for example, create and show new DynamicForm with different fields in an existing Layout.
We have "autoDraw" set to false, so we call show() for the form. After calling show(), we initialize fields with values by calling field.setValue(..). Note, that if call field.getValue() right after that, it returns the correct value.
Let say, first field of the form is a date field and it automatically (or sometimes randomly) receives the focus after the form is drawn.
Then we have a script running on a small timeout to reset tab indexes for all elements on the page. We have to do it every time when a part of the page is changed since the default tab index is set according to the drawing order. This script goes through all Canvas elements and its children and calls setTabIndex() for all focusable items.
Resetting tab index causes focus movement. Sometimes blur happens for the date field BEFORE the native element has the actual field value. Blur handler calls updateValue() that pulls the current native element value (which is still null) and nullifies the field value.
I set a conditional breakpoint at updateValue() in browser and I saw that at the moment of the blur event the field value is actually correct (“_value” member) and the form and fields are displayed and drawn on the page, but don’t have any values displayed yet.
Sorry, I was unable to reproduce it with an example in your feature explorer or standalone. Since it seems to be a timing issue, it is tough to provide an isolated example.
So, my questions are:
1) How we can force to propagate the field value to the native element of the text or date field? The paradox is that field is drawn already, and even has the focus, but do not have field value set for some reason.
2) Maybe there is a safer way to reset tab indexes on the page, without moving focus around? But I guess, this is just one case, blur also may happen due to other page changes or redrawing.
Increasing a timeout for the script helps a bit but does not solve the issue; even with 500ms timeout it still happens, although less frequently.
3) How can we prevent from calling blur() on the element that is not fully initialized yet? For example, can we “deactivate” somehow current focus item before resetting indexes?
-----
SmartClient : SC_SNAPSHOT-2011-02-10 (2011-02-10)
GWT: 2.1.0
We DO NOT use Smart GWT.
Browsers: IE 7&8, Firefox 3.6
Comment