Closed Bug 1397271 Opened 8 years ago Closed 8 years ago

Browser action popup reopens after clicking link that creates a new tab

Categories

(WebExtensions :: Untriaged, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: TheOne, Unassigned)

References

()

Details

The browser action popup closes when clicking on a link in the popup that has something like "onclick='browser.tabs.create(...)'. After the tab has been created (and selected), the popup reopens. See URL for an add-on where this happens. This looks weird, especially since all the content in the popup is lost and needs to be rebuild. Is this intended?
Try adding event.preventDefault to your calls eg: +++ b/popup/popup.js @@ -79,14 +79,16 @@ document.querySelector("#signInLink").addEventListener("click", async() => { window.close(); }); -document.querySelector("#openCustomPage").addEventListener("click", () => { +document.querySelector("#openCustomPage").addEventListener("click", (event) => { browser.tabs.create({ url: "../custom/custom.html" }); + event.preventDefault(); }); -document.querySelector("#resetPersona").addEventListener("click", () => { +document.querySelector("#resetPersona").addEventListener("click", (event) => { reset(); + event.preventDefault(); }); And you won't see the close and the flicker.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
Thank you, Andy!
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.