>>>>> On Thu, 19 Mar 2015 10:20:27 -0400, Kito Mann <kito.mann_at_virtua.com> said:
KM> Hello everyone,
KM> One of the annoying things about Ajax updates with JSF is the fact that
KM> focus can easily get lost. One of my clients actually resorted to
KM> synchronous "Ajax" requests to avoid this problem (to my chagrin). Here's a
KM> good description/solution to the problem:
KM>
http://www.knitelius.com/2014/07/15/keeping-focus-on-element-with-jsf-2-ajax-render/
KM> .
KM> Given that this is a common pain point, shouldn't we provide a solution out
KM> of the box?
>>>>> On Sun, 12 Apr 2015 16:35:42 -0700, Edward Burns <edward.burns_at_oracle.com> said:
EB> I'm all for making things simple by default, but how is this not an
EB> implementation issue given the following?
>>>>> On Thu, 2 Apr 2015 17:29:15 +0200, Bauke Scholtz <balusc_at_gmail.com> said:
B> Hi,
B> Haven't checked MyFaces, but this problem doesn't occur in Mojarra. I
B> recall that this problem was indeed addressed about two years ago, I only
B> can't find the associated issue report and fix version anymore. The jsf.js
B> was been altered to recognize input elements and then only copy the
B> attributes instead of the whole element.
EB> What needs to change in the spec?
MM> Remembering the last active element would be a fine solution.
MM> Or, we might introduce something like
MM> <f:ajax execute="..." render="..." focus="elementId"/>
MM> elementId = someId|_at_this|_at_current
MM> The focus will be set only, and only if this optional attribute is
MM> provided.
MM> Such an attribute might offer more flexibility than just the current
MM> element.
I like the simplicity of this proposal but I think we need to specify a
default behavior. How about we add to the spec that the ajax request
should sample document.activeElement [1] before sending the request and
set the focus to that element after doing the innerHTML replacement?
For the attribute name, I prefer afterFocus. If the afterFocus
attribute is set, the focus must be set to that element after the
innerHTML replacement.
Ed
--
| edward.burns_at_oracle.com | office: +1 407 458 0017
| 1 days til CONFESS 2015
[1] http://davidwalsh.name/focused-element