Fix swappable jQuery focus behavior
Per the Google group discussion:
The JS for swappable is incorrect. It currently sets focus to the top-level markup element and then tries to additionally set focus on all direct child input elements (although there is also a bug in the selector used.)
This issue is obvious in the completed ToDo code provided in the Getting Started guide; when changing the description on a ToDo item, clicking the static text makes the input visible, but focus is not set. This is due to the surrounding span itself receiving focus on swap, and the input selector on direct children being skipped due to syntactical issues.
Desired behavior would be to have the top-level element tested as an input and focused on match; else focus set only on the first matching descendant input, a la:
visible.onclick = function() {
jQuery(visible).hide();
jQuery(hidden).show();
if (jQuery(hidden).is("input"))
jQuery(hidden).focus();
else
jQuery(hidden).find("input")[0].focus();
return false;
};
The JS for swappable is incorrect. It currently sets focus to the top-level markup element and then tries to additionally set focus on all direct child input elements (although there is also a bug in the selector used.)
This issue is obvious in the completed ToDo code provided in the Getting Started guide; when changing the description on a ToDo item, clicking the static text makes the input visible, but focus is not set. This is due to the surrounding span itself receiving focus on swap, and the input selector on direct children being skipped due to syntactical issues.
Desired behavior would be to have the top-level element tested as an input and focused on match; else focus set only on the first matching descendant input, a la:
visible.onclick = function() {
jQuery(visible).hide();
jQuery(hidden).show();
if (jQuery(hidden).is("input"))
jQuery(hidden).focus();
else
jQuery(hidden).find("input")[0].focus();
return false;
};
Leave a comment
on 2010-04-03 08:10 *
By marius.danciu
Milestone set to Lift 2.0-M5
Status changed from New to Accepted
on 2010-05-16 02:33 *
By marius.danciu
on review board.