Bug 697121 - Keep focus on entry while typing on AwesomeBar (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 28 Oct 2011 16:09:34 +0100
changeset 81672 0b65a47a160c5329b279b33f162cec8001bad7a0
parent 81671 ddc7b89fa4d6b3f777ff69b7c669cf10e4bc2ebf
child 81673 6963a1ada9b62f91d6610bb6c743456bb5c69697
push idunknown
push userunknown
push dateunknown
reviewersmfinkle
bugs697121
milestone10.0a1
Bug 697121 - Keep focus on entry while typing on AwesomeBar (r=mfinkle) When user types on AwesomeBar's entry, we always switch to 'All Pages' tab to show the filtered results. Tab switching was causing the tab content to steal focus from the search entry.
embedding/android/AwesomeBarTabs.java
--- a/embedding/android/AwesomeBarTabs.java
+++ b/embedding/android/AwesomeBarTabs.java
@@ -536,19 +536,25 @@ public class AwesomeBarTabs extends TabH
         if (mBookmarksAdapter != null) {
             Cursor bookmarksCursor = mBookmarksAdapter.getCursor();
             if (bookmarksCursor != null)
                 bookmarksCursor.close();
         }
     }
 
     public void filter(String searchTerm) {
+        // Don't let the tab's content steal focus on tab switch
+        setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
+
         // Ensure the 'All Pages' tab is selected
         setCurrentTabByTag(ALL_PAGES_TAB);
 
+        // Restore normal focus behavior on tab host
+        setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
+
         // The tabs should only be visible if there's no on-going search
         int tabsVisibility = (searchTerm.length() == 0 ? View.VISIBLE : View.GONE);
         getTabWidget().setVisibility(tabsVisibility);
 
         // Perform the actual search
         mAllPagesAdapter.getFilter().filter(searchTerm);
     }
 }