diff --git a/api-samples/default_command_override/background.js b/api-samples/default_command_override/background.js index ecf9de2325..42c4b698da 100644 --- a/api-samples/default_command_override/background.js +++ b/api-samples/default_command_override/background.js @@ -13,9 +13,9 @@ chrome.commands.onCommand.addListener(async (command) => { const lastTab = tabs.length - 1; let newIndex = -1; if (command === 'flip-tabs-forward') { - newIndex = activeIndex === 0 ? lastTab : activeIndex - 1; + newIndex = activeIndex === lastTab ? 0 : activeIndex + 1; } // 'flip-tabs-backwards' - else newIndex = activeIndex === lastTab ? 0 : activeIndex + 1; + else newIndex = activeIndex === 0 ? lastTab : activeIndex - 1; chrome.tabs.update(tabs[newIndex].id, { active: true, highlighted: true }); });