From 5431639ce26b8412fb7241d90e5c3ad8cec94b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20L=C3=B6rincz?= Date: Mon, 1 May 2023 16:17:04 +0200 Subject: [PATCH] added length to avoid error (#892) check tabIds.length avoid error --- functional-samples/tutorial.tabs-manager/popup.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functional-samples/tutorial.tabs-manager/popup.js b/functional-samples/tutorial.tabs-manager/popup.js index cb2eb2c6..ed4d730b 100644 --- a/functional-samples/tutorial.tabs-manager/popup.js +++ b/functional-samples/tutorial.tabs-manager/popup.js @@ -46,6 +46,8 @@ document.querySelector('ul').append(...elements); 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' }); + } });