Skip to content

[BUGFIX] fix panel links menu positioning#157

Open
ayanarukasar wants to merge 1 commit into
perses:mainfrom
ayanarukasar:fix-panel-links-menu-position
Open

[BUGFIX] fix panel links menu positioning#157
ayanarukasar wants to merge 1 commit into
perses:mainfrom
ayanarukasar:fix-panel-links-menu-position

Conversation

@ayanarukasar

@ayanarukasar ayanarukasar commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes panel link dropdown menus appearing at arbitrary screen positions instead of next to the link icon.

The menu was portaled to document.body, which breaks positioning inside react-grid-layout panels that use CSS transforms. This change disables the portal for panel link menus and anchors the menu below the link icon.

Fixes perses/perses#3654

Screenshots

After

image image

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the naming convention.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.

@ayanarukasar ayanarukasar requested a review from a team as a code owner June 10, 2026 07:25
@jgbernalp

Copy link
Copy Markdown
Contributor

@ayanarukasar can you please follow the PR template checks and include some screenshots or tests when relevant.

@ayanarukasar

Copy link
Copy Markdown
Contributor Author

@jgbernalp Thanks for the review! I've updated the PR description to follow the template and added a screenshot showing the panel links menu opening next to the link icon.

>
<OnHover>
{descriptionAction} {linksAction}
{descriptionAction} {links && links.length > 0 && <LinksDisplay links={links} variant="panel" />}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could be shortened no?

links?.length > 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shahrokni Good catch — updated all three occurrences to use links?.length > 0. Also rebased onto latest main. Thanks!

>
<OnHover>
{descriptionAction} {linksAction}
{descriptionAction} {links && links.length > 0 && <LinksDisplay links={links} variant="panel" />}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ayanarukasar ayanarukasar force-pushed the fix-panel-links-menu-position branch 2 times, most recently from 414fb20 to 899818b Compare June 10, 2026 11:37
@jgbernalp

Copy link
Copy Markdown
Contributor

@ayanarukasar Is the image depicting the previous behavior? It seems the dropdown is not next to the link button

@ayanarukasar

ayanarukasar commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@jgbernalp You're right — the previous screenshot didn't show the fix correctly.

disablePortal alone wasn't enough; react-grid-layout CSS transforms still broke MUI Menu positioning. I've updated the fix to use Popper with strategy: 'fixed' for panel links (same approach as OverflowMenu), and render separate LinksDisplay instances per header breakpoint.

Squashed into a single commit (8f808f2), rebased on latest main, and retested locally — the menu now opens directly below the link icon. Updated screenshot attached.

@ayanarukasar ayanarukasar force-pushed the fix-panel-links-menu-position branch from 5d1d8c0 to 8f808f2 Compare June 10, 2026 15:45
Comment thread dashboards/src/components/Panel/PanelActions.tsx Outdated
@ayanarukasar ayanarukasar force-pushed the fix-panel-links-menu-position branch from 8f808f2 to bce52ec Compare June 11, 2026 10:34
Comment thread dashboards/src/components/Annotations/AnnotationsEditor.tsx
Panel link dropdowns appeared at arbitrary screen positions inside
react-grid-layout panels that use CSS transforms. Render a fresh
LinksDisplay instance per header breakpoint via renderPanelLinks() and
use Popper with strategy: fixed so the menu stays anchored below the
link icon.

Fixes perses/perses#3654

Signed-off-by: Ayana-Rukasar <ayanark1515@gmail.com>
@ayanarukasar ayanarukasar force-pushed the fix-panel-links-menu-position branch from bce52ec to 2ca6f7d Compare June 11, 2026 11:19
@jgbernalp

Copy link
Copy Markdown
Contributor

I wonder if disabling portaling altogether would make the code simpler, as right now we are almost duplicating the same code with or without portal. Does this issue also applies for other context menus like actions or editing, for example when the menu is collapsed in a panel that has no name?

@ayanarukasar

Copy link
Copy Markdown
Contributor Author

@jgbernalp Good questions!

On portaling: I tried disablePortal first, but MUI Menu positioning was still wrong inside react-grid-layout panels (CSS transforms). Popper with strategy: 'fixed' is what fixed it — same general approach as OverflowMenu in PanelActions. Dashboard-level links aren't inside transformed grid items, so the standard Menu still works there. We could unify both variants on the Popper pattern in a follow-up, but I kept this PR scoped to the reported bug.

On other menus: OverflowMenu already uses Popper rather than portaled Menu, so it's less likely to hit the same issue. Panel links also had a second cause — a shared linksAction element bound to a hidden responsive branch — which renderPanelLinks() fixes. I haven't seen the same mispositioning on overflow/edit menus locally, but happy to file a separate issue to audit other panel menus if useful.

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.

Panel link container is placed on an arbitrary position on the screen

3 participants