Skip to content

bugfix/5155-roots-panel-openmenu-undefined#5291

Merged
msureshkumar88 merged 3 commits into
mainfrom
bugfix/5155-roots-panel-openmenu-undefined
Jul 2, 2026
Merged

bugfix/5155-roots-panel-openmenu-undefined#5291
msureshkumar88 merged 3 commits into
mainfrom
bugfix/5155-roots-panel-openmenu-undefined

Conversation

@Nayana-R-Gowda

@Nayana-R-Gowda Nayana-R-Gowda commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Signed-off-by: NAYANA.R nayana.r7813@gmail.com

closes #5155

What Changed

  • File: mcpgateway/templates/admin.html:7938
  • Before: x-data="window.Admin?.overflowMenu?.('roots-table-wrapper')"
  • After: x-data="overflowMenu('roots-table-wrapper')"

Root cause: Alpine evaluates the x-data expression as JavaScript. With optional chaining (?.), when window.Admin or window.Admin.overflowMenu resolves to undefined at init time, Alpine initializes the component with an empty scope — menuOpen and openMenu are never defined. Clicking the button then tries to call openMenu() which doesn't exist → "Undefined variable: openMenu".

Signed-off-by: NAYANA.R <nayana.r7813@gmail.com>
@ja8zyjits

Copy link
Copy Markdown
Collaborator

@Nayana-R-Gowda Please add tests

Signed-off-by: NAYANA.R <nayana.r7813@gmail.com>
Signed-off-by: NAYANA.R <nayana.r7813@gmail.com>

@marekdano marekdano left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The user-facing bug is correctly fixed!

LGTM 🚀

@vishu-bh vishu-bh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @Nayana-R-Gowda!

changes are clean.
LGTM ☘️

@msureshkumar88 msureshkumar88 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified this fixes #5155 end-to-end in a real browser (Chromium via Playwright, against a live admin server).

Repro (pre-fix code, x-data="window.Admin?.overflowMenu?.('roots-table-wrapper')"): created a root, clicked the row's overflow-menu button → reproduced the exact reported error:

Error: Undefined variable: openMenu

With this PR's fix (x-data="overflowMenu('roots-table-wrapper')"): same click → no console errors, dropdown opens correctly (menuOpen toggles as expected).

Root cause write-up is accurate — overflowMenu is registered via Alpine.data('overflowMenu', overflowMenu), not attached to window.Admin, so the old optional-chaining expression always evaluated to undefined and Alpine initialized the component with an empty scope.

Diff is minimal and well-scoped: template one-liner, a doc-comment clarifying the correct usage pattern, and solid regression coverage in overflow-menu.test.js (including a test that reproduces the broken expression directly). Nothing to flag on correctness or cleanup.

@msureshkumar88 msureshkumar88 added this pull request to the merge queue Jul 2, 2026
Merged via the queue into main with commit a88604e Jul 2, 2026
43 checks passed
@msureshkumar88 msureshkumar88 deleted the bugfix/5155-roots-panel-openmenu-undefined branch July 2, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Roots panel action menu throws 'Undefined variable: openMenu' — wrong x-data pattern

5 participants