Skip to content

fix(authoring): context menu flickers at previous position - #451

Merged
leowla merged 2 commits into
masterfrom
vps-115-context-menus-noticeably-flicker-at-previous-position
Aug 28, 2026
Merged

fix(authoring): context menu flickers at previous position#451
leowla merged 2 commits into
masterfrom
vps-115-context-menus-noticeably-flicker-at-previous-position

Conversation

@K1mmyn

@K1mmyn K1mmyn commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Issue

The main cause for the flicker is that, the current function which create the context menu check onmouseup if your cursor is on a piece of html which is apart of the context menu. This bug happens when you are holding right click and move your cursor off the context menu and release right click.

adjustedPosition is never cleared when the menu closes so the next open paints one frame at the previous menu's coordinates before the effect corrects it

Solution

Change from mouseup to mousedown because it is guaranteed that the mouse will start on top of the context menu due to negative offset

useLayoutEffect to adjust first before paint

Risk

NONE

Checklist

  • Acceptance criteria met
  • Continuous integration build passing

Summary by CodeRabbit

  • Bug Fixes
    • Improved context menu click-away handling by responding when the mouse button is pressed, providing more consistent dismissal behavior.

@linear

linear Bot commented Jul 26, 2026

Copy link
Copy Markdown

VPS-115

@K1mmyn
K1mmyn requested review from GogaIV and hazikchaudhry July 26, 2026 00:57
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Context menu event handling

Layer / File(s) Summary
Update click-away event binding
frontend/src/components/ContextMenu/portal.jsx
clickAwayListener now removes and registers a document-level passive mousedown listener instead of a mouseup listener.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: fixing context-menu flickering at its previous position.
Description check ✅ Passed The description includes the required Issue, Solution, Risk, and Checklist sections. It explains the stale adjustedPosition issue and the useLayoutEffect solution. Some checklist items remain unchecke…
Full details: Description check

Explanation

The description includes the required Issue, Solution, Risk, and Checklist sections. It explains the stale adjustedPosition issue and the useLayoutEffect solution. Some checklist items remain unchecked, but the description is mostly complete.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vps-115-context-menus-noticeably-flicker-at-previous-position

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@GogaIV GogaIV left a comment

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.

I mean i guesss

@harbassan harbassan left a comment

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.

Virtual.Patient.System.-.UoA.Mozilla.Firefox.2026-07-27.23-38-02.mp4

@GogaIV
GogaIV self-requested a review July 27, 2026 11:45

@GogaIV GogaIV left a comment

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.

Screencast_20260727_235200.webm
it is working for me idk hartej, im on firefox browser
the other sort of flicker thats happening seems to be from the previous context menu location so could not be closing properly or smthn like that

@harbassan

Copy link
Copy Markdown
Contributor

yeah i think that tiny flicker you have at the start of your video is the one im having all the time, where there is a render that happens at the previous location before a rerender at the new location.

The adjusted position was kept in state but never cleared when the menu
closed, so reopening it painted one frame at the previous menu's
coordinates. The correction also ran in useEffect, i.e. after paint, so
that wrong frame was visible.

Move the measurement to useLayoutEffect so it lands before paint, and
reset the stored position when the menu unmounts.

Claude-Session: https://claude.ai/code/session_01YDsqKXLrLfr6u22sh1VFFx
@leowla
leowla requested a review from harbassan August 28, 2026 02:17
@leowla leowla changed the title vps-115-context-menus-noticeably-flicker-at-previous-position fix(authoring): context menu flickers at previous position Aug 28, 2026

@harbassan harbassan left a comment

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.

works

@leowla
leowla merged commit eb169de into master Aug 28, 2026
3 checks passed
@leowla
leowla deleted the vps-115-context-menus-noticeably-flicker-at-previous-position branch August 28, 2026 03:22
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.

4 participants