Skip to content

Fix SelectPanel close button alignment in narrow viewports #6327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

liuliu-dev
Copy link
Contributor

@liuliu-dev liuliu-dev commented Jul 16, 2025

Closes #5446


🐛 Problem

When primer_react_select_panel_fullscreen_on_narrow feature flag is enabled, the close button (X) rendered by AnchoredOverlay is misaligned with the SelectPanel header text in narrow viewports. The close button (32px tall, centered) doesn't align with the h1 header text (21px line-height, flex-start aligned).

Added CSS rule to adjust the title margin for anchored variant SelectPanels in narrow viewports, following the same pattern used by the modal variant:

.Wrapper[data-variant='anchored'] .Title {
  @media screen and (--viewportRange-narrow) {
    margin-top: var(--base-size-8);
  }
}
Before After
Close Button Before Close Button After

🔮 Future Work

This is a temporary fix for the dual close buttons. After primer_react_select_panel_fullscreen_on_narrow feature flag is removed, we should:

  1. Consolidate to a single close button (currently we have 2 options: close button in AnchoredOverlay or close button in SelectPanel wrapper)
  2. Remove this CSS workaround

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

  • Verify alignment in Storybook with primer_react_select_panel_fullscreen_on_narrow enabled.

Merge checklist

@Copilot Copilot AI review requested due to automatic review settings July 16, 2025 16:44
@liuliu-dev liuliu-dev requested a review from a team as a code owner July 16, 2025 16:44
@liuliu-dev liuliu-dev requested a review from pksjce July 16, 2025 16:44
Copy link

changeset-bot bot commented Jul 16, 2025

🦋 Changeset detected

Latest commit: d764b63

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

Copy link
Contributor

@Copilot 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

This PR fixes a visual alignment issue in the SelectPanel component where the close button rendered by AnchoredOverlay was not properly aligned with the header text in narrow viewports when the primer_react_select_panel_fullscreen_on_narrow feature flag is enabled.

  • Adds CSS rule to position the close button with proper top offset in narrow viewports
  • Updates Storybook example to include subtitle for better testing coverage
  • Includes temporary workaround documentation with TODO for future cleanup

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/SelectPanel/SelectPanel.module.css Adds CSS rule to align close button positioning in narrow viewports for anchor variant
packages/react/src/SelectPanel/SelectPanel.features.stories.tsx Adds subtitle to Storybook example for testing the alignment fix
.changeset/silver-melons-relate.md Documents the change as a major version bump

Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@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 Jul 16, 2025
@liuliu-dev liuliu-dev marked this pull request as draft July 16, 2025 16:46
Copy link
Contributor

github-actions bot commented Jul 16, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 91.9 KB (0%)
packages/react/dist/browser.umd.js 92.23 KB (0%)

@github-actions github-actions bot requested a deployment to storybook-preview-6327 July 16, 2025 16:49 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6327 July 16, 2025 16:58 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-6327 July 16, 2025 18:33 Inactive
@liuliu-dev liuliu-dev marked this pull request as ready for review July 16, 2025 18:59
@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jul 16, 2025
Copy link
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@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 Jul 17, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6327 July 17, 2025 16:52 Inactive
@primer primer bot requested a review from a team as a code owner July 17, 2025 17:04
@primer primer bot requested a review from mperrotti July 17, 2025 17:04
@github-actions github-actions bot removed update snapshots integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jul 17, 2025
Copy link
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@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 Jul 17, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6327 July 17, 2025 17:12 Inactive
@liuliu-dev liuliu-dev force-pushed the liuliu/fix-selectpanel-close-button-alignment branch from b4d63a2 to d764b63 Compare July 17, 2025 17:26
@github-actions github-actions bot removed the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jul 17, 2025
Copy link
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@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 Jul 17, 2025
@github-actions github-actions bot removed the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jul 17, 2025
@primer-integration
Copy link

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

@primer-integration
Copy link

🟢 golden-jobs completed with status success.

@pksjce
Copy link
Contributor

pksjce commented Jul 20, 2025

Hi 👋
Why can't we directly do the future work now instead of the workaround?

@liuliu-dev
Copy link
Contributor Author

liuliu-dev commented Jul 21, 2025

Hi 👋 Why can't we directly do the future work now instead of the workaround?

@pksjce Good question! We currently have two close button implementations:

  1. SelectPanel's own IconButton (modal variant on wide screens)
  2. AnchoredOverlay's built-in close button (anchored variant on narrow screens when feature flag is enabled)

We could consolidate these now, but it's safer to wait until the primer_react_select_panel_fullscreen_on_narrow feature flag is removed since people are still using it. Changing the close button architecture while the flag is active could potentially break things for existing users.

This fix just addresses the alignment issue with the AnchoredOverlay button for now. The feature flags removal is planned for a few weeks from now, once the flag is removed, we can pick one approach and clean this up properly.

@pksjce
Copy link
Contributor

pksjce commented Jul 22, 2025

Great! Would be nice to have a tracking ticket where you can put in this context and pick it back up when everything is ready?

Copy link
Contributor

@pksjce pksjce left a comment

Choose a reason for hiding this comment

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

I was able to test it and moving the title element with margin seems to fix the issue. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants