Closed
Bug 1486050
Opened 6 years ago
Closed 6 years ago
Impossible to change multiselection state of tabs by setting "highlighted" attribute of tabs without focus change
Categories
(WebExtensions :: General, enhancement, P5)
WebExtensions
General
Tracking
(firefox63 verified)
VERIFIED
FIXED
mozilla63
Tracking | Status | |
---|---|---|
firefox63 | --- | verified |
People
(Reporter: yuki, Assigned: Oriol)
Details
(Keywords: dev-doc-complete)
Attachments
(2 files)
By the bug 1479129 now I can set multiselection state of tabs by setting "highlight" to true via browser.tabs.update(). However there is a side effect: it always activate the newly highlighted tab. Due to this restriction, any addon cannot simulate Firefox's tab multiselection behavior for Shift-click on its custom tabbar-like UI, ex: Tree Style Tab addon. # Steps to reproduce 1. Prepare multiple tabs. Assume that there are two tabs: * [tabA, id=1, active=true, highlighted=true] * [tabB, id=2] 2. Execute browser.tabs.update(2, { highlighted: true, active: false }); # Actual result The originally activated tab become inactive and the newly highlighted tab become active: * [tabA, id=1, highlighted=true] * [tabB, id=2, active=true, highlighted=true] # Expected result The originally activated tab stays active: * [tabA, id=1, active=true, highlighted=true] * [tabB, id=2, highlighted=true] # Additional info This behavior is quite same to Google Chrome, but I think the expected behavior is quite necessary. Even if it breaks compatibility with Chrome's API, I think it is reasonable that updating with "{ highlighted: true, active: false }" to set tab's highlighted state without any side effect, as an advantage behavior of Firefox's WebExtensions API.
Reporter | ||
Comment 1•6 years ago
|
||
There is a workaround: ``` const tabs = await browser.tabs.query({}); const activeTabId = tabs.filter(tab => tab.active)[0].id; // 1. set non-active multiselected tabs highlighted. It changes focus of tabs. for (const tab of tabs) { if (!tab.active) browser.tabs.update(tab.id, { highlighted: true }); } // 2. set old active tab to unhighlighted // (because setting highlighted=true for already highlighted tab does nothing) browser.tabs.update(activeTabId, { highlighted: false }); // 3. set old active tab to highlighted browser.tabs.update(activeTabId , { highlighted: true }); ``` but it produces annoying flicking of the content area.
Comment 2•6 years ago
|
||
Oriol: I agree with the need to be able to set highlight without active, and we kind of touched on this during a recent review. Can we support a non-chrome behavior if both highlighted and active are supplied to update?
Flags: needinfo?(oriol-bugzilla)
Comment 3•6 years ago
|
||
I agree that breaking with Chrome behavior in this case makes sense.
Severity: normal → enhancement
Priority: -- → P5
Assignee | ||
Comment 4•6 years ago
|
||
(In reply to YUKI "Piro" Hiroshi from comment #1) > There is a workaround: > but it produces annoying flicking of the content area. I guess another workaround which avoids flickering would be async function highlightTabWithoutActivating(tabId) { let {index, windowId} = await browser.tabs.get(tabId); let indices = [index]; let highlighted = await browser.tabs.query({windowId, highlighted: true}); for (let {index, active} of highlighted) indices[active ? "unshift" : "push"](index); return browser.tabs.highlight({windowId, tabs: indices}); } But I agree it's annoying that {highlighted: true, active: false} doesn't work with tabs.update. Shouldn't be much difficult to implement.
Assignee: nobody → oriol-bugzilla
Status: NEW → ASSIGNED
Flags: needinfo?(oriol-bugzilla)
Assignee | ||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Comment on attachment 9003939 [details] Bug 1486050 - Don't change selected tab when browser.tabs.update is called with {highlighted: true, active: false}. r=mixedpuppy Shane Caraveo (:mixedpuppy) has approved the revision.
Attachment #9003939 -
Flags: review+
Assignee | ||
Updated•6 years ago
|
Keywords: checkin-needed,
dev-doc-needed
Pushed by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/84d0017964b6 Don't change selected tab when browser.tabs.update is called with {highlighted: true, active: false}. r=mixedpuppy
Keywords: checkin-needed
Comment 8•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/84d0017964b6
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Comment 9•6 years ago
|
||
Verified as fixed using Firefox 63.0b(20180904170936) with Windows 10x64 and macOS 10.13.6. I will attach a postfix video.
Updated•6 years ago
|
Status: RESOLVED → VERIFIED
Updated•6 years ago
|
Comment 10•6 years ago
|
||
Comment 11•6 years ago
|
||
Created a pull request for browser compatibility status and added the following to 63 release notes (): {{WebExtAPIRef("tabs.update")}} now supports changing the selection status of a tab without changing the focused tab ({{bug(1486050)}}).
Flags: needinfo?(oriol-bugzilla)
Keywords: dev-doc-needed → dev-doc-complete
Assignee | ||
Comment 12•6 years ago
|
||
I have clarified the interaction of active and highlighted in https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/update
Flags: needinfo?(oriol-bugzilla)
You need to log in
before you can comment on or make changes to this bug.
Description
•