To ensure focus and scrollTo don't conflict (when possible), I set the focus order on page show to 1) previously clicked item if revisiting that page 2) page title 3) first focusable item in the page. Fixes #1342

This commit is contained in:
scottjehl 2011-04-07 16:27:32 -04:00
parent b4088b9422
commit 97f5a9565f

View file

@ -237,8 +237,13 @@
//direct focus to the page title, or otherwise first focusable element
function reFocus( page ){
var pageTitle = page.find( ".ui-title:eq(0)" );
if( pageTitle.length ){
var pageTitle = page.find( ".ui-title:eq(0)" ),
lastClicked = page.jqmData( "lastClicked" );
if( lastClicked && lastClicked.length ){
lastClicked.focus();
}
else if( pageTitle.length ){
pageTitle.focus();
}
else{
@ -396,7 +401,9 @@
if( from ){
//set as data for returning to that spot
from.jqmData( "lastScroll", currScroll);
from
.jqmData( "lastScroll", currScroll)
.jqmData( "lastClicked", $activeClickedLink);
//trigger before show/hide events
from.data( "page" )._trigger( "beforehide", null, { nextPage: to } );
}