Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Make sure there are tabs before manipulating them.
Browse files Browse the repository at this point in the history
Addresses #7601 

@AmySteam This seems like a reasonable addition to this code sample. You probably wouldn't be trying to run it unless you had tabs open to documentation, but it's also probably easy to overlook. How many hours have we all wasted because silly minor thing we need to do.

This is already in the related sample.
  • Loading branch information
jpmedley authored Oct 30, 2023
1 parent f3b2245 commit 47c9f0b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions site/en/docs/extensions/mv3/getstarted/tut-tabs-manager/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ seoTitle: 'Chrome Extensions Tutorial: Manage tabs'
subhead: 'Build your first tabs manager.'
description: 'Learn how to programmatically organize tabs using tab groups.'
date: 2022-10-04
# updated: 2022-06-13
updated: 2022-10-30
---

## Overview {: #overview }
Expand Down Expand Up @@ -272,12 +272,13 @@ In `popup.js`, add the following code to create a button that will group all the
move them into the current window.

```js
...
const button = document.querySelector("button");
button.addEventListener("click", async () => {
const button = document.querySelector('button');
button.addEventListener('click', async () => {
const tabIds = tabs.map(({ id }) => id);
const group = await chrome.tabs.group({ tabIds });
await chrome.tabGroups.update(group, { title: "DOCS" });
if (tabIds.length) {
const group = await chrome.tabs.group({ tabIds });
await chrome.tabGroups.update(group, { title: 'DOCS' });
}
});
```

Expand Down

1 comment on commit 47c9f0b

@AmySteam
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to merge these changes, we have to change them on the sample too. I don't have bandwidth for this right now, especially since this code will change.

Please sign in to comment.