Skip to content

Commit 10cb102

Browse files
noisysocksclaude
andauthored
Fix context menu by filtering fake widgets starting with underscore (#1888)
The context menu was including fake widgets (like _omnibar-toggleAi for Duck.ai toggle) which caused issues with native app integration. This change: - Updates useContextMenu() to filter out all widgets with IDs starting with '_' - Renames debug widget ID from 'debug' to '_debug' for consistency - Adds integration test to verify only real widgets appear in context menu 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 7d4f327 commit 10cb102

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

special-pages/pages/new-tab/app/customizer/components/CustomizerMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function useContextMenu() {
4747
const items = getItems();
4848
/** @type {VisibilityMenuItem[]} */
4949
const simplified = items
50-
.filter((x) => x.id !== 'debug')
50+
.filter((x) => !x.id.startsWith('_'))
5151
.map((item) => {
5252
return {
5353
id: item.id,

special-pages/pages/new-tab/app/omnibar/integration-tests/omnibar.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,4 +936,25 @@ test.describe('omnibar widget', () => {
936936
await omnibar.closeButton().click();
937937
await omnibar.expectInputValue('');
938938
});
939+
940+
test('context menu only includes real widgets, not fake ones', async ({ page }, workerInfo) => {
941+
const ntp = NewtabPage.create(page, workerInfo);
942+
const omnibar = new OmnibarPage(ntp);
943+
944+
await ntp.reducedMotion();
945+
await ntp.openPage({ additional: { omnibar: true } });
946+
await omnibar.ready();
947+
948+
// Right-click on the page to trigger context menu
949+
await page.click('body', { button: 'right' });
950+
951+
// Assert that contextMenu notification is sent with real widgets and not e.g. the Duck.ai toggle
952+
await omnibar.expectMethodCalledWith('contextMenu', {
953+
visibilityMenuItems: [
954+
{ id: 'omnibar', title: 'Search' },
955+
{ id: 'favorites', title: 'Favorites' },
956+
{ id: 'protections', title: 'Protections Report' },
957+
],
958+
});
959+
});
939960
});

special-pages/pages/new-tab/app/telemetry/Debug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function DebugCustomized({ index, isOpenInitially = false }) {
1010
const telemetry = useTelemetry();
1111
useCustomizer({
1212
title: '🐞 Debug',
13-
id: 'debug',
13+
id: '_debug',
1414
icon: <DuckFoot />,
1515
visibility: isOpen ? 'visible' : 'hidden',
1616
toggle: (_id) => setOpen((prev) => !prev),

0 commit comments

Comments
 (0)