Permalink
Browse files

To ensure focus and scrollTo don't conflict (when possible), I set th…

…e 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
  • Loading branch information...
1 parent b4088b9 commit 97f5a9565f31df7d15181bf27a328f86160e0ed9 scottjehl committed Apr 7, 2011
Showing with 10 additions and 3 deletions.
  1. +10 −3 js/jquery.mobile.navigation.js
View
13 js/jquery.mobile.navigation.js
@@ -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();
@staabm
staabm Aug 22, 2011

why do you use focus() and not scrollIntoView() to scroll to the element?

+ }
+ 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 } );
}

0 comments on commit 97f5a95

Please sign in to comment.