Skip to content

fix: scale selection label arrow for narrow labels#165

Merged
aidenybai merged 1 commit intomainfrom
fix/arrow-size-narrow-labels
Feb 7, 2026
Merged

fix: scale selection label arrow for narrow labels#165
aidenybai merged 1 commit intomainfrom
fix/arrow-size-narrow-labels

Conversation

@aidenybai
Copy link
Owner

@aidenybai aidenybai commented Feb 7, 2026

Summary

  • Scale the selection label arrow size proportionally to the inner panel width so it no longer overflows on short tag names like p
  • Extract arrow sizing into a shared getArrowSize utility used by both the Arrow component and label positioning logic
  • Use actual computed arrow height for label positioning to eliminate the gap between arrow and panel

Test plan

  • Hover over elements with short tag names (e.g. p, b, i) and verify the arrow fits within the label
  • Hover over elements with longer tag names (e.g. div, section) and verify the arrow remains the default size
  • Verify no gap between arrow and label panel in both above/below positions

Made with Cursor


Note

Low Risk
UI-only sizing/positioning changes scoped to the selection label arrow, with minimal blast radius and no data/security impact.

Overview
Fixes selection label arrows overflowing narrow labels by scaling the CSS triangle size dynamically via a shared getArrowSize utility.

SelectionLabel now measures the inner panel width and uses the computed arrow height for above/below positioning, while ArrowProps gains an optional labelWidth to drive the new sizing behavior.

Written by Cursor Bugbot for commit 7677809. This will update automatically on new commits. Configure here.


Summary by cubic

Scaled the selection label arrow to fit narrow labels and used the real arrow height for positioning to remove the gap. Wide labels keep the default arrow size.

  • Bug Fixes

    • Scales arrow via label width to prevent overflow on short tags (e.g., p, b, i).
    • Uses computed arrow height for positioning to eliminate the panel gap.
    • Clamps size between a minimum and the default to keep wide labels unchanged.
  • Refactors

    • Added a shared getArrowSize utility used by the Arrow and positioning logic.
    • Measured panel width and passed it to Arrow; extended ArrowProps with labelWidth.

Written for commit 7677809. Summary will update on new commits.

The arrow (16px wide) overflowed labels with short tag names like "p".
Arrow size now scales based on the inner panel width via a shared
getArrowSize utility, and label positioning uses the actual arrow
height to eliminate gaps.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
Copy link
Contributor

vercel bot commented Feb 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-grab-website Error Error Feb 7, 2026 8:45am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 7, 2026

Open in StackBlitz

@react-grab/cli

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/cli@165

grab

npm i https://pkg.pr.new/aidenybai/react-grab/grab@165

@react-grab/ami

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/ami@165

@react-grab/amp

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/amp@165

@react-grab/claude-code

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/claude-code@165

@react-grab/codex

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/codex@165

@react-grab/cursor

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/cursor@165

@react-grab/droid

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/droid@165

@react-grab/gemini

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/gemini@165

@react-grab/opencode

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/opencode@165

react-grab

npm i https://pkg.pr.new/aidenybai/react-grab@165

@react-grab/relay

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/relay@165

@react-grab/utils

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/utils@165

commit: 7677809

Copy link
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

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

Critical timing bug: Arrow renders before panelWidth is measured, causing scaling to fail on initial render.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow runpullfrog.com𝕏

position={arrowPosition()}
leftPercent={computedPosition().arrowLeftPercent}
leftOffsetPx={computedPosition().arrowLeftOffset}
labelWidth={panelWidth()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Critical bug: The Arrow component renders before panelRef is assigned (line 405). When Arrow initially renders, panelWidth() returns 0, causing getArrowSize(0) to return the default ARROW_HEIGHT_PX (8px) instead of the scaled size.

The arrow will only get the correct size on subsequent re-renders after measureContainer runs. On first render with short labels, you'll still see the overflow issue that this PR aims to fix.

Solution: Move the Arrow after the panelRef div, or add a conditional render that waits for panelWidth() > 0.

const selectionBottom = bounds.y + bounds.height;
const selectionTop = bounds.y;

const actualArrowHeight = getArrowSize(panelWidth());
Copy link
Contributor

Choose a reason for hiding this comment

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

This uses panelWidth() which is 0 during initial render. The positioning calculations will use the wrong arrow height (8px fallback) on first render, potentially causing the gap between arrow and panel that the PR description says it eliminates.

Comment on lines +9 to +10
const scaledSize = labelWidth * ARROW_MAX_LABEL_WIDTH_RATIO;
return Math.max(ARROW_MIN_SIZE_PX, Math.min(ARROW_HEIGHT_PX, scaledSize));
Copy link
Contributor

Choose a reason for hiding this comment

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

For very narrow labels (15px wide), this produces 3px which gets clamped to 4px. Is 4px arrow still too large for the narrowest cases? The ratio and minimum should be validated against actual short tag names like p, b, i mentioned in the test plan.


export const ARROW_HEIGHT_PX = 8;
export const ARROW_MIN_SIZE_PX = 4;
export const ARROW_MAX_LABEL_WIDTH_RATIO = 0.2;
Copy link
Contributor

Choose a reason for hiding this comment

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

The 20% ratio seems arbitrary. For a 30px label, arrow becomes 6px. Was this tested visually? Consider documenting the rationale.

@pullfrog
Copy link
Contributor

pullfrog bot commented Feb 7, 2026

Additional Finding: Context Menu Missing Same Fix

The context-menu.tsx component also renders an Arrow component (line 245-249) but wasn't updated to pass the labelWidth prop. This means:

  1. Context menu arrows won't benefit from the same scaling logic
  2. Context menus with short labels will have the same overflow issue this PR fixes for selection labels
  3. The ArrowProps type now has an optional labelWidth field that context-menu doesn't provide

Recommendation: Apply the same pattern to context-menu.tsx:

  • Add a ref to track the menu panel width
  • Pass that width to the Arrow component
  • Use the same measurement timing approach

This would ensure consistent arrow sizing across both selection labels and context menus.

Pullfrog  | Triggered by Pullfrog | Using Claude CodeView workflow runpullfrog.com𝕏

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

@aidenybai aidenybai merged commit d708441 into main Feb 7, 2026
13 of 14 checks passed
divyanshudhruv pushed a commit to divyanshudhruv/react-grab that referenced this pull request Mar 4, 2026
…denybai#165)

The arrow (16px wide) overflowed labels with short tag names like "p".
Arrow size now scales based on the inner panel width via a shared
getArrowSize utility, and label positioning uses the actual arrow
height to eliminate gaps.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant