Skip to content

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

Merged
liuliu-dev merged 7 commits intomainfrom
liuliu/fix-banner-stack-actions-on-narrow-viewport
Mar 11, 2026
Merged

fix(Banner): stack inline actions vertically on narrow viewports#7625
liuliu-dev merged 7 commits intomainfrom
liuliu/fix-banner-stack-actions-on-narrow-viewport

Conversation

@liuliu-dev
Copy link
Contributor

@liuliu-dev liuliu-dev commented Mar 4, 2026

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-05 at 1 16 46 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: c614cbb

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.

@github-actions github-actions bot temporarily deployed to storybook-preview-7625 March 4, 2026 21:56 Inactive
@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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch on keyboard focus @copilot!

I initially used column-reverse to put the primary button on top, this is how it looks after switched to column to keep visual order aligned with focus order:

Screenshot 2026-03-05 at 1 04 12 PM

Curious what you think about this @lukasoppermann 👀

Copy link
Contributor

Choose a reason for hiding this comment

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

The idea was actually that on small view ports the buttons are below:
CleanShot 2026-03-06 at 10 20 11@2x

Wonder why this is not working. Would it be possible to fix it like that? The text is very narrow if it is in two columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the issue is specifically from the actionsLayout="inline" story, which overrides the default responsive behavior. From the docs:

Screenshot 2026-03-06 at 8 38 22 AM

When actionsLayout is inline, the container has nowrap which prevents wrapping at all viewport sizes. Should we allow inline to fall back to stacked at narrow viewports? or it should always stay inline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed with @lukasoppermann that we will stack on narrow view port:

inline is meant for the non-mobile view, where adding the x normally moves the buttons below, which can be bad if all you have is a very short title.

So for mobile, lets fall back to stacked.

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? 🙏🏽

@liuliu-dev liuliu-dev added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Mar 10, 2026
@github-actions github-actions bot requested a deployment to storybook-preview-7625 March 10, 2026 17:58 Abandoned
@primer primer bot requested a review from a team as a code owner March 10, 2026 18:08
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Mar 10, 2026
@github-actions github-actions bot temporarily deployed to storybook-preview-7625 March 10, 2026 18:09 Inactive
@primer-integration
Copy link

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

@primer-integration
Copy link

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Waiting  Projects   Waiting

@liuliu-dev liuliu-dev added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh integration-tests: skipped manually Changes in this PR do not require an integration test and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh labels Mar 11, 2026
@liuliu-dev
Copy link
Contributor Author

skipping integration tests as github-ui/projects check passed(https://github.com/github/github-ui/actions/runs/22926785736/job/66651741620), but not reported back.

@liuliu-dev liuliu-dev added this pull request to the merge queue Mar 11, 2026
Merged via the queue into main with commit 2e8c707 Mar 11, 2026
63 checks passed
@liuliu-dev liuliu-dev deleted the liuliu/fix-banner-stack-actions-on-narrow-viewport branch March 11, 2026 16:00
@primer primer bot mentioned this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: skipped manually Changes in this PR do not require an integration test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants