Description
I have an AjaxButton. Its onSubmit() handler calls AjaxRequestTarget.focusComponent(). After the Ajax response is handled, that component should get the focus, but it does not. Wicket.Focus.setFocusOnId() is called correctly and it does set the lastFocusId field, but Wicket.Focus.requestFocus() finds that Wicket.Focus.refocusLastFocusedComponentAfterResponse is false and does nothing.
What happens is that, before Wicket.Focus.requestFocus() runs (it scheduled by the first response via setTimeout(0), so it is not synchronous) another Ajax response is handled. This calls markFocusComponent(), then check checkFocusedComponentReplaced(). The latter method (correctly) determines the focused component was not replaced by the second Ajax response, so it sets Wicket.Focus.refocusLastFocusedComponentAfterResponse to false. When requestFocus() does run, later, it thinks it is just supposed to refocus the component that already has the focus.
The second Ajax response is triggered by wicket-atmosphere, but to me this issue is not caused by wicket-atmosphere. The core problem is that two Ajax responses can clobber each other's focus-related state in Wicket.Focus.
Attachments
Issue Links
- breaks
-
WICKET-5755 Restoring focus after Ajax replace no longer works in IE8
- Resolved
-
WICKET-5858 AjaxRequestTarget.focusComponent does not work in modal window
- Resolved