Closed Bug 822068 Opened 12 years ago Closed 12 years ago

The content loses focus after calling gBrowser.moveTabBackward/moveTabForward

Categories

(Firefox :: Tabbed Browser, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 20

People

(Reporter: tabutils+bugzilla, Assigned: tabutils+bugzilla)

References

Details

Attachments

(1 file, 1 obsolete file)

this.mCurrentTab.focus() should not be called directly in gBrowser.moveTabBackward/moveTabForward. http://mxr.mozilla.org/mozilla-central/source/browser/base/content/tabbrowser.xml#2248
Attached patch patch (obsolete) — Splinter Review
Attachment #692677 - Flags: review?(dao)
OS: Windows 7 → All
Hardware: x86_64 → All
Summary: The tab element is focused after calling gBrowser.moveTabBackward/moveTabForward → The content loses focus after calling gBrowser.moveTabBackward/moveTabForward
Blocks: 364845
Comment on attachment 692677 [details] [diff] [review] patch >+ let wasFocused = false; >+ try { >+ wasFocused = (document.commandDispatcher.focusedElement == this.mCurrentTab); >+ } catch (e) {} > this.mCurrentTab._selected = false; Use document.activeElement and add a blank line after your code. > // use .item() instead of [] because dragging to the end of the strip goes out of > // bounds: .item() returns null (so it acts like appendChild), but [] throws > this.tabContainer.insertBefore(aTab, this.tabs.item(aIndex)); > > for (let i = 0; i < this.tabs.length; i++) { > this.tabs[i]._tPos = i; > this.tabs[i]._selected = false; > } > this.mCurrentTab._selected = true; >+ if (wasFocused) >+ this.mCurrentTab.focus(); Add a blank line before your code. > this.tabContainer._handleTabSelect(false); >- > if (aTab.pinned) > this.tabContainer._positionPinnedTabs(); Avoid this change. r=me with these things addressed
Attachment #692677 - Flags: review?(dao) → review+
(In reply to Dão Gottwald [:dao] from comment #2) > > >+ let wasFocused = false; > >+ try { > >+ wasFocused = (document.commandDispatcher.focusedElement == this.mCurrentTab); > >+ } catch (e) {} > > this.mCurrentTab._selected = false; > > Use document.activeElement and add a blank line after your code. Is there any difference here? I read that there're several instances using document.commandDispatcher.focusedElement in tabbox.xml, so I copied it here. And If I use document.activeElement, I assume try ... catch is no more needed?
Yes, try/catch isn't needed. document.activeElement is the standard way to do this. document.commandDispatcher.focusedElement is a proprietary Mozilla thing that you may need when dealing with anonymous content, which isn't the case here.
Attachment #692677 - Attachment is obsolete: true
Keywords: checkin-needed
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 20
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: