Skip to content

Bugfix: Fix dropdown caret position in CSS styles for clean borders#4061

Merged
lesliecdubs merged 6 commits intomainfrom
lcw/dropdown-arrows-are-broken
May 4, 2026
Merged

Bugfix: Fix dropdown caret position in CSS styles for clean borders#4061
lesliecdubs merged 6 commits intomainfrom
lcw/dropdown-arrows-are-broken

Conversation

@lesliecdubs
Copy link
Copy Markdown
Member

@lesliecdubs lesliecdubs commented May 1, 2026

What are you trying to accomplish?

In the PRC Dropdown component, most of the borders on the arrows are broken. South works, but the rest do not. This is an attempt to manually adjust the CSS controlling arrow position to fix the bad 1px offset.

Screenshots

Look closely, we're adjusting the small 1px border on the side of the dropdown menu's arrow.

Before After
Dropdown e activated with arrow that has a missing border Dropdown e activated with arrow with 1px border on all relevant sides
Dropdown ne activated with arrow that has a missing border Dropdown ne activated with arrow with 1px border on all relevant sides
Dropdown se activated with arrow that has a missing border Dropdown se activated with arrow with 1px border on all relevant sides
Dropdown sw activated with arrow that has a missing border Dropdown sw activated with arrow with 1px border on all relevant sides
Dropdown w activated with arrow that has a missing border Dropdown w activated with arrow with 1px border on all relevant sides

List the issues that this change affects.

Closes https://github.com/github/primer/issues/5370

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

CSS is fun

Anything you want to highlight for special attention from reviewers?

Check the Lookbook stories for Dropdown, click each dropdown, and ensure the arrow borders are correct. Best to check cross-browser too.

Accessibility

  • No new axe scan violation - This change does not introduce any new axe scan violations.

Merge checklist

  • Added/updated tests
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@lesliecdubs lesliecdubs self-assigned this May 1, 2026
Copilot AI review requested due to automatic review settings May 1, 2026 21:46
@lesliecdubs lesliecdubs requested a review from a team as a code owner May 1, 2026 21:46
@lesliecdubs lesliecdubs requested a review from llastflowers May 1, 2026 21:46
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: 0168aa2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a visual bug in the Primer::Alpha Dropdown caret “arrow” rendering by adjusting the caret pseudo-element positioning so borders align cleanly across dropdown directions.

Changes:

  • Adjusted ::after caret top offset for west/east dropdown menus to correct a 1px misalignment.
  • Adjusted horizontal offsets (left/right) for ::after caret positioning in NE/SW/SE directions to remove a 1px offset.
Show a summary per file
File Description
app/components/primer/alpha/dropdown.pcss Tweaks caret pseudo-element offsets for multiple dropdown directions to correct arrow border alignment.

Copilot's findings

Comments suppressed due to low confidence (2)

app/components/primer/alpha/dropdown.pcss:296

  • Same concern as the other directional carets: left: 9px is a hard-coded adjustment that likely represents var(--base-size-8) + 1px. Using token-based calc (e.g., calc(var(--base-size-8) + var(--borderWidth-thin))) makes the intended relationship clearer and reduces reliance on raw px values.
    top: -14px;
    /* stylelint-disable-next-line primer/spacing */
    left: 9px;
  }

app/components/primer/alpha/dropdown.pcss:198

  • Same as the .dropdown-menu-w caret: switching from a token to a hard-coded 11px introduces a magic number and needs a stylelint suppression. Prefer a token-based expression (e.g., calc(var(--base-size-12) - var(--borderWidth-thin))) so the offset remains tied to the design system scale.
    /* stylelint-disable-next-line primer/spacing */
    top: 11px;
    /* stylelint-disable-next-line primer/spacing */
    left: -14px;
    border-color: transparent;
  • Files reviewed: 1/1 changed files
  • Comments generated: 4

Comment thread app/components/primer/alpha/dropdown.pcss
Comment thread app/components/primer/alpha/dropdown.pcss
Comment thread app/components/primer/alpha/dropdown.pcss
Comment thread app/components/primer/alpha/dropdown.pcss
@lesliecdubs lesliecdubs marked this pull request as draft May 1, 2026 21:51
…eractive snapshots

Agent-Logs-Url: https://github.com/primer/view_components/sessions/21064b25-d326-406d-afc9-e158fe24f157

Co-authored-by: lesliecdubs <3902488+lesliecdubs@users.noreply.github.com>
@lesliecdubs
Copy link
Copy Markdown
Member Author

@copilot add a changeset to this PR. This is a patch. Changelog entry: "Fix Dropdown component caret position in CSS styles for clean borders"

Agent-Logs-Url: https://github.com/primer/view_components/sessions/1518ebf1-0bff-47cb-8434-6fbc1832fe87

Co-authored-by: lesliecdubs <3902488+lesliecdubs@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

@copilot add a changeset to this PR. This is a patch. Changelog entry: "Fix Dropdown component caret position in CSS styles for clean borders"

Added in 37cea36.changeset/fix-dropdown-caret-borders.md with a patch bump for @primer/view-components.

@lesliecdubs
Copy link
Copy Markdown
Member Author

@copilot autofix any of the stylelint failures that you can. Then look at the other failures and see if you can address them.

Agent-Logs-Url: https://github.com/primer/view_components/sessions/a244c473-8a12-4c20-9380-eaf9cfdf56c2

Co-authored-by: lesliecdubs <3902488+lesliecdubs@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

@copilot autofix any of the stylelint failures that you can. Then look at the other failures and see if you can address them.

Fixed in 0168aa2. Changes made to dropdown.pcss:

  • Removed 6 needless primer/spacing disable comments — functional spacing tokens like --control-small-paddingBlock and --stack-gap-condensed are now valid in @primer/stylelint-config@13.6.0, so those suppression comments were flagged as needless.
  • Replaced deprecated box-shadowvar(--shadow-floating-legacy, var(--color-shadow-large))var(--shadow-floating-small), which is the correct Primer variable in @primer/primitives v11.
  • Restored 5 primer/spacing disable comments — the calc() expressions mixing spacing and border tokens (e.g. calc(var(--base-size-12) - var(--borderWidth-thin))) still need suppression since --borderWidth-thin is not a spacing variable.

Verified with npx stylelint --rd -q app/components/primer/alpha/dropdown.pcss — 0 errors.

@lesliecdubs
Copy link
Copy Markdown
Member Author

lesliecdubs commented May 1, 2026

👋🏻 Hey @llastflowers, looks like you got pulled in as reviewer. Do you know if there's a way to get a Lookbook preview for this PR so we can manually verify these changes cross-browser? Or is there another way to test?

Copy link
Copy Markdown
Contributor

@llastflowers llastflowers left a comment

Choose a reason for hiding this comment

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

Looks so much better, yay! ✨

@lesliecdubs lesliecdubs requested a review from jonrohan May 1, 2026 22:49
@lesliecdubs
Copy link
Copy Markdown
Member Author

lesliecdubs commented May 1, 2026

👋🏻 Hey @llastflowers, looks like you got pulled in as reviewer. Do you know if there's a way to get a Lookbook preview for this PR so we can manually verify these changes cross-browser? Or is there another way to test?

@jonrohan we weren't sure if there was a way to check Lookbook from a PR, can you confirm or teach us? Feel free to 👀s the code too

Nevermind, we found it! But happy to have an extra set of 👀 s on this before we run with it 🙏🏻

@llastflowers
Copy link
Copy Markdown
Contributor

Looks good on Safari too!

Copy link
Copy Markdown
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

Looks good thanks for fixing it 👍🏻

@lesliecdubs lesliecdubs merged commit b732a9f into main May 4, 2026
32 checks passed
@lesliecdubs lesliecdubs deleted the lcw/dropdown-arrows-are-broken branch May 4, 2026 21:40
@primer primer Bot mentioned this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants