Closed
Bug 626338
Opened 14 years ago
Closed 14 years ago
Searchbox doesn't get the focus if it's activated using the search button
Categories
(Firefox Graveyard :: Panorama, defect, P2)
Firefox Graveyard
Panorama
Tracking
(Not tracked)
VERIFIED
FIXED
Firefox 4.0b11
People
(Reporter: raymondlee, Assigned: raymondlee)
References
Details
(Keywords: regression, Whiteboard: [ux][polish][good first bug])
Attachments
(1 file, 4 obsolete files)
7.68 KB,
patch
|
Details | Diff | Splinter Review |
Steps to reproduce
1. Go the panorama view and press the search button
2. The searchbox is displayed
Actual:
The searchbox doesn't get the focus
Expected:
The searchbox should have the focus in it
Assignee | ||
Updated•14 years ago
|
Assignee: nobody → raymond
Assignee | ||
Comment 1•14 years ago
|
||
Attachment #504391 -
Flags: review?(ian)
Assignee | ||
Updated•14 years ago
|
Keywords: regression
Comment 2•14 years ago
|
||
Hourly regression range:
works 2011-01-14 20110114051941 616a453859c6
broken 2011-01-14 20110114054626 c02435684f58
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=616a453859c6&tochange=c02435684f58
bug 610821
Comment 3•14 years ago
|
||
Comment on attachment 504391 [details] [diff] [review]
v1
>- setTimeout(function dispatchTabViewSearchEnabledEvent() {
>+ let dispatchTabViewSearchEnabledEvent = function() {
> let newEvent = document.createEvent("Events");
> newEvent.initEvent("tabviewsearchenabled", false, false);
> dispatchEvent(newEvent);
>- }, 0);
>+ };
>+
>+ if (activatedByKeypress) {
>+ $searchbox[0].focus();
>+ setTimeout(function dispatchSearchEnabledEvent() {
>+ dispatchTabViewSearchEnabledEvent();
>+ }, 0);
>+ } else {
>+ setTimeout(function setFocusAndDispatchSearchEnabledEvent() {
>+ $searchbox[0].focus();
>+ dispatchTabViewSearchEnabledEvent();
>+ }, 0);
>+ }
Perhaps you could add a comment here for why the different code paths?
>+ browser_tabview_bug626338.js \
Seems like this test could just be rolled into browser_tabview_search.js?
Also might be good to verify that entering with a key also activates focus (if we're not already doing that somewhere).
Attachment #504391 -
Flags: review?(ian) → review-
Updated•14 years ago
|
Assignee | ||
Comment 4•14 years ago
|
||
(In reply to comment #3)
> Comment on attachment 504391 [details] [diff] [review]
> v1
>
> >- setTimeout(function dispatchTabViewSearchEnabledEvent() {
> >+ let dispatchTabViewSearchEnabledEvent = function() {
> > let newEvent = document.createEvent("Events");
> > newEvent.initEvent("tabviewsearchenabled", false, false);
> > dispatchEvent(newEvent);
> >- }, 0);
> >+ };
> >+
> >+ if (activatedByKeypress) {
> >+ $searchbox[0].focus();
> >+ setTimeout(function dispatchSearchEnabledEvent() {
> >+ dispatchTabViewSearchEnabledEvent();
> >+ }, 0);
> >+ } else {
> >+ setTimeout(function setFocusAndDispatchSearchEnabledEvent() {
> >+ $searchbox[0].focus();
> >+ dispatchTabViewSearchEnabledEvent();
> >+ }, 0);
> >+ }
>
> Perhaps you could add a comment here for why the different code paths?
Done.
>
> >+ browser_tabview_bug626338.js \
>
> Seems like this test could just be rolled into browser_tabview_search.js?
Merged the test into browser_tabview_search.js
>
> Also might be good to verify that entering with a key also activates focus (if
> we're not already doing that somewhere).
Added that in browser_tabview_bug595560.js
Attachment #504391 -
Attachment is obsolete: true
Assignee | ||
Updated•14 years ago
|
Attachment #505635 -
Flags: review?(ian)
Comment 5•14 years ago
|
||
Comment on attachment 505635 [details] [diff] [review]
v2
>+ if (activatedByKeypress) {
>+ $searchbox[0].focus();
>+ setTimeout(function dispatchSearchEnabledEvent() {
>+ dispatchTabViewSearchEnabledEvent();
>+ }, 0);
>+ } else {
>+ // marshal the focusing, otherwise it ends up with searchbox[0].focus gets
>+ // called before the search button gets the focus after being pressed.
>+ setTimeout(function setFocusAndDispatchSearchEnabledEvent() {
>+ $searchbox[0].focus();
>+ dispatchTabViewSearchEnabledEvent();
>+ }, 0);
>+ }
Thanks for adding the comment. What about the other code path? Why the setTimeout for the event? Can you add a comment for that? Just trying to make sure future generations know what we were up to. :)
Folding the test into those other tests looks great!
r+ with the additional comment
Attachment #505635 -
Flags: review?(ian) → review+
Assignee | ||
Comment 6•14 years ago
|
||
I've removed the setTimeout in other code path but it breaks one of the tests. I've fixed that test now so request another review.
Attachment #505635 -
Attachment is obsolete: true
Attachment #505710 -
Flags: review?(ian)
Assignee | ||
Comment 7•14 years ago
|
||
(In reply to comment #6)
> Created attachment 505710 [details] [diff] [review]
> v3
>
> I've removed the setTimeout in other code path but it breaks one of the tests.
> I've fixed that test now so request another review.
Passed Try!
Comment 8•14 years ago
|
||
Comment on attachment 505710 [details] [diff] [review]
v3
(I'm doing some feedback to help Ian on reviews.)
>-function ensureSearchShown(){
>+function ensureSearchShown(activatedByKeypress) {
Please add a standard format comment above the function.
>- setTimeout(function dispatchTabViewSearchEnabledEvent() {
>+ let dispatchTabViewSearchEnabledEvent = function() {
Please actually name the function, too, so that we can see it in debug stacks.
> let searchBox = contentWindow.iQ("#searchbox");
>+
>+ ok(searchBox[0].focus, "The search box has focus");
element.focus is a DOM method... it will always be not false.
You need to check both document.hasFocus() and that document.activeElement == searchBox[0].
http://www.whatwg.org/specs/web-apps/current-work/#focus-management
> let onSearchEnabled = function() {
>- let searchBox = contentWindow.document.getElementById("searchbox");
>- is(searchBox.value, number, "The seach box matches the number: " + number);
>- contentWindow.hideSearch(null);
>+ // ensure the dom changes (textbox get focused with number entered) complete
>+ // before doing a check.
>+ executeSoon(function() {
>+ let searchBox = contentWindow.document.getElementById("searchbox");
>+ is(searchBox.value, number, "The seach box matches the number: " + number);
>+ contentWindow.hideSearch(null);
>+ });
This probably works, but why not bind a "change" event listener to the searchBox?
>diff --git a/browser/base/content/test/tabview/browser_tabview_search.js b/browser/base/content/test/tabview/browser_tabview_search.js
>+ let searchBox = contentWindow.document.getElementById("searchbox");
>+ ok(searchBox.focus, "The search box has focus");
Same here.
Attachment #505710 -
Flags: review?(ian) → feedback-
Assignee | ||
Comment 9•14 years ago
|
||
(In reply to comment #8)
> Comment on attachment 505710 [details] [diff] [review]
> v3
>
> (I'm doing some feedback to help Ian on reviews.)
>
> >-function ensureSearchShown(){
> >+function ensureSearchShown(activatedByKeypress) {
>
> Please add a standard format comment above the function.
>
Done
> >- setTimeout(function dispatchTabViewSearchEnabledEvent() {
> >+ let dispatchTabViewSearchEnabledEvent = function() {
>
> Please actually name the function, too, so that we can see it in debug stacks.
Done
>
> > let searchBox = contentWindow.iQ("#searchbox");
> >+
> >+ ok(searchBox[0].focus, "The search box has focus");
>
> element.focus is a DOM method... it will always be not false.
>
> You need to check both document.hasFocus() and that document.activeElement ==
> searchBox[0].
>
> http://www.whatwg.org/specs/web-apps/current-work/#focus-management
Updated. Thanks for the info.
>
> > let onSearchEnabled = function() {
> >- let searchBox = contentWindow.document.getElementById("searchbox");
> >- is(searchBox.value, number, "The seach box matches the number: " + number);
> >- contentWindow.hideSearch(null);
> >+ // ensure the dom changes (textbox get focused with number entered) complete
> >+ // before doing a check.
> >+ executeSoon(function() {
> >+ let searchBox = contentWindow.document.getElementById("searchbox");
> >+ is(searchBox.value, number, "The seach box matches the number: " + number);
> >+ contentWindow.hideSearch(null);
> >+ });
>
> This probably works, but why not bind a "change" event listener to the
> searchBox?
>
I will keep it is since this test works fine.
> >diff --git a/browser/base/content/test/tabview/browser_tabview_search.js b/browser/base/content/test/tabview/browser_tabview_search.js
> >+ let searchBox = contentWindow.document.getElementById("searchbox");
> >+ ok(searchBox.focus, "The search box has focus");
>
> Same here.
Updated.
Attachment #505710 -
Attachment is obsolete: true
Attachment #505855 -
Flags: review?(ian)
Comment 10•14 years ago
|
||
Comment on attachment 505855 [details] [diff] [review]
v4
Looks great!
Attachment #505855 -
Flags: feedback+
Comment 11•14 years ago
|
||
Comment on attachment 505855 [details] [diff] [review]
v4
Lovely
Attachment #505855 -
Flags: review?(ian) → review+
Assignee | ||
Updated•14 years ago
|
Attachment #505855 -
Flags: approval2.0?
Assignee | ||
Comment 12•14 years ago
|
||
Sent it to try and waiting for the result
Assignee | ||
Comment 14•14 years ago
|
||
(In reply to comment #12)
> Sent it to try and waiting for the result
Passed Try!
Comment 15•14 years ago
|
||
Comment on attachment 505855 [details] [diff] [review]
v4
a=beltzner, thanks for the tests!
Attachment #505855 -
Flags: approval2.0? → approval2.0+
Assignee | ||
Comment 16•14 years ago
|
||
Attachment #505855 -
Attachment is obsolete: true
Assignee | ||
Updated•14 years ago
|
Keywords: checkin-needed
Comment 17•14 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 4.0b11
Updated•9 years ago
|
Product: Firefox → Firefox Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•