Skip to content

fix(Banner): stack inline actions vertically on narrow viewports#7625

Open
liuliu-dev wants to merge 2 commits intomainfrom
liuliu/fix-banner-stack-actions-on-narrow-viewport
Open

fix(Banner): stack inline actions vertically on narrow viewports#7625
liuliu-dev wants to merge 2 commits intomainfrom
liuliu/fix-banner-stack-actions-on-narrow-viewport

Conversation

@liuliu-dev
Copy link
Contributor

Addresses issue #14971

Changelog

Fixes an overlap issue in Banner when actionsLayout="inline" is used with both a primary and secondary action at narrow viewport (320×256px).

Solution: At narrow viewports (--viewportRange-narrow), the trailing actions container switches to flex-direction: column-reverse, stacking the primary and secondary action buttons vertically.

Before:

Screenshot 2026-03-04 at 1 32 07 PM

After:

Screenshot 2026-03-04 at 1 32 31 PM

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 047bfd6

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

This PR includes changesets to release 1 package
Name Type
@primer/react 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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Uh oh! @liuliu-dev, at least one image you shared is missing helpful alt text. Check your pull request body to fix the following violations:

  • Images should have meaningful alternative text (alt text) at line 15
  • Images should have meaningful alternative text (alt text) at line 19

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@primer
Copy link
Contributor

primer bot commented Mar 4, 2026

🤖 Lint issues have been automatically fixed and committed to this PR.

@primer-integration
Copy link

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/15162

@primer-integration
Copy link

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

@liuliu-dev liuliu-dev marked this pull request as ready for review March 4, 2026 22:24
@liuliu-dev liuliu-dev requested a review from a team as a code owner March 4, 2026 22:25
Copy link
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

Adjusts @primer/react’s Banner styling to prevent inline action buttons from overlapping at narrow viewport widths, addressing an accessibility-audits issue.

Changes:

  • Add a narrow-viewport media rule for inline (actionsLayout="inline") trailing actions to stack vertically.
  • Add a patch changeset entry for the Banner fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/react/src/Banner/Banner.module.css Changes inline trailing actions layout at narrow viewports to avoid button overlap.
.changeset/gold-rooms-bake.md Declares a patch release for the Banner layout adjustment.

display: flex;

@media screen and (--viewportRange-narrow) {
flex-direction: column-reverse;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

Using flex-direction: column-reverse will make the visual order of the actions differ from DOM/focus order (Banner renders secondaryAction before primaryAction in the trailing container). On narrow viewports this can cause keyboard focus to move bottom→top, which is an accessibility issue. Prefer flex-direction: column (to keep visual order aligned with focus order), or otherwise change the rendered DOM order for this breakpoint so visual and focus order match.

Suggested change
flex-direction: column-reverse;
flex-direction: column;

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

tested and this seems to be correct 👀 let's address it

display: flex;

@media screen and (--viewportRange-narrow) {
flex-direction: column-reverse;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

When switching this container to a column layout, the existing spacing defined on .BannerActionsContainer via column-gap won’t add vertical spacing between stacked buttons. Consider adding a row-gap/gap override for the narrow breakpoint (or switching the base container to gap) so the vertically stacked actions don’t touch.

Suggested change
flex-direction: column-reverse;
flex-direction: column-reverse;
row-gap: var(--base-size-2);

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +46
@media screen and (--viewportRange-narrow) {
flex-direction: column-reverse;
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

This change fixes a narrow-viewport layout issue, but the existing Banner stories don’t currently cover actionsLayout="inline" at ~320px with both primary and secondary actions (the mobile example only shows a primary action). Adding/updating a Storybook case (and corresponding VRT/AVT coverage if applicable) for inline+two-actions at narrow widths would help prevent regressions.

Copilot uses AI. Check for mistakes.
Copy link
Member

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

Lets address https://github.com/primer/react/pull/7625/changes#r2891377700
Would also be nice to add VRT on narrow for this if possible 👀
Aaaand can we get design to sign off on the new narrow visuals? 🙏🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants