#1671

fix: float the command menu over the composer instead of pushing it down

Openjubianchiwants to merge intofrom

Summary

Typing / in a fresh commit draft opened the /feature and /bug menu inside the composer, so the composer's actions and the whole page under it jumped down 100px, and back up when it closed. The mention, emoji, issue and guild suggestions float over the page instead. This makes the command menu float the same way, so nothing moves when it opens.

The jump grows with the menu: every command added to it pushes the page down further. Several open PRs add some:

  • #1669 lists /shrug and /tableflip after /feature and /bug;
  • #359 adds /image (/img), /poll and /code, and moves the commands into the field's own suggestion menu, which floats already: if it lands first, this one has nothing left to fix;
  • #367 adds /gif once a GIF provider key is set.

With a floating menu, a longer list only takes more room over the page, not in it.

Changes

  1. Floating menu. IssueCommandSuggestions renders in a portal, fixed under the slash that starts the draft, with the same popover surface as the field's suggestions. It follows the page when it scrolls or resizes, and opens above the slash near the bottom of the viewport.
  2. Shared placement. The code placing the field's suggestions moves from MentionTextarea to lib/suggestion-position.ts as suggestionPositionAt(), used by both. MentionTextarea behaves as before.
  3. Composer dialog. The dialog already lets clicks through to [data-command-suggestions], so the menu can go past the dialog's edge instead of making it grow.
  4. Key hints. At the suggestions' width, the hints wrap between ↑↓ select, Tab or Enter pick and Esc dismiss rather than inside one.

Validation

CheckResult
pest --parallel --coverage --exactly=100.0 (full suite)6516 passed, 100.0%
pest --type-coverage --min=100100.0%
tsc --noEmit (app and tests)clean
vp test (TSX unit tests)110 files, 1113 passed
node --test tests/Unit/*.test.ts333 passed
vp fmt --check, vp lintclean

All local; hosted CI runs once a maintainer approves the workflow.

Visual evidence

Playwright (Chromium) against a local dev server with seeded data, signed in as the local developer, typing / in an empty draft. Before is production (0e09618a), after is this branch.

Layout shift, measured on the Log at 1440×900 from before typing to the menu being open:

BeforeAfter
Commit button moves100px down0px
First commit below moves100px down0px
Layout shift score (PerformanceObserver)0.0240
BeforeAfter
Log composer, 1440 light
Log composer, 1440 dark
Composer dialog (c), 1440 light
Dialog reopened on the restored / draft, 1440 light
Before, 390 lightAfter, 390 light

Device verification

Emulation only (390×844, DPR 2, touch) in Chromium: no hardware or simulator. On a phone the menu floats under the slash like the mention suggestions do, over the actions instead of pushing them below the fold.

Independent review

A fresh read-only reviewer, given the guidelines, the diff, the validation results and the captures, checked the move of the placement code, server rendering, the first paint, the dialog's outside-click and Escape handling, the keys and the tests. On base 0e09618a, head 2828c49b: CODE: PASS, VISUAL: PASS. Applied in b85795ae, with tests:

  • the menu measures again when an animation ends, so a dialog reopened on a restored / draft doesn't leave it where the dialog was while zooming in (checked in the browser: it sits under the slash);
  • pressing on the menu's padding or hints keeps the focus in the field, as with the field's suggestions, instead of closing the menu;
  • each · starts the hint after it, so none is left at the end of a line.

Limitations

  • Like the field's suggestions, the open menu covers the composer's toolbar under it; picking a command or pressing Esc uncovers it.
  • The menu keeps the field's suggestions' 288px width, narrower than before, so its hints take two lines.

Summary by CodeRabbit

  • Bug Fixes
    • Issue-command and other suggestion menus now appear beside the relevant text entry point and adjust their position when the viewport changes.
    • Menus wait until the text field is available before appearing, reducing misplaced suggestions.

Activity

2
coderabbitai[bot]9d ago

No actionable comments were generated in the recent review.

Walkthrough

Textarea suggestion positioning now uses a shared character-position helper. Issue-command suggestions receive the composer’s textarea ref, recalculate their position on relevant viewport and animation events, and render in a fixed-position portal.

Changes: Suggestion positioning

Layer / File(s)Summary
Shared textarea position calculation
resources/js/lib/suggestion-position.ts, resources/js/components/mention-textarea.tsx
The shared helper measures a textarea character and calculates its viewport-aware position. MentionTextarea uses it to place and reposition suggestions.
Anchored issue-command menu
resources/js/components/issue-command.tsx, resources/js/components/commit-composer.tsx, tests/Unit/IssueCommandSuggestions.test.tsx, tests/Unit/ComposerDraft.test.tsx
IssueCommandSuggestions uses the textarea anchor to position a fixed menu in a portal. Tests cover anchor wiring, menu rendering, position updates, and listener cleanup.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant CommitComposer
  participant IssueCommandSuggestions
  participant useSlashPosition
  participant suggestionPositionAt
  participant document.body
  CommitComposer->>IssueCommandSuggestions: Passes textareaRef as anchor
  IssueCommandSuggestions->>useSlashPosition: Requests anchor position
  useSlashPosition->>suggestionPositionAt: Measures anchor at index 0
  suggestionPositionAt-->>useSlashPosition: Returns viewport position
  useSlashPosition-->>IssueCommandSuggestions: Provides measured position
  IssueCommandSuggestions->>document.body: Portals fixed-position menu

Possibly related PRs

Suggested reviewers: nunomaduro, brendt, xheaven

Merge Risk: Minimal · up to b8579

The change makes the slash-command menu float over the composer instead of pushing the layout down, and it shares the position calculation with the mention menu. No concrete defects were found, and the dialog's outside-click handling already treats the command menu as part of the dialog. Merge risk is minimal.

Pre-merge checks: 4

Check nameStatusExplanation
Description CheckCheck skipped - CodeRabbit’s high-level summary is enabled.
Title checkThe title names the main change: the slash-command menu (IssueCommandSuggestions) now floats over the composer through a viewport-fixed portal instead of pushing the composer and page down. The change…
Linked Issues checkCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkCheck skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the slash-command menu (IssueCommandSuggestions) now floats over the composer through a viewport-fixed portal instead of pushing the composer and page down. The changeset adds the portal, the useSlashPosition recalculation, and the anchor prop, and the objectives confirm this is the primary purpose. The title is specific and short, and it fits the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b650f3f9-908e-4f6c-8cb6-a08b8196bc7a
Commits

Reviewing files that changed from the base of the PR and between 0e09618a7765cf6f92a53b6ddb9a1a79e49c46b6 and b85795aeb39ee30f339746749af63dfd054aca60.

Files selected for processing: 6

  • resources/js/components/commit-composer.tsx
  • resources/js/components/issue-command.tsx
  • resources/js/components/mention-textarea.tsx
  • resources/js/lib/suggestion-position.ts
  • tests/Unit/ComposerDraft.test.tsx
  • tests/Unit/IssueCommandSuggestions.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.