Skip to content
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

SelectPanel: Add variant=modal #5817

Closed
wants to merge 28 commits into from
Closed

SelectPanel: Add variant=modal #5817

wants to merge 28 commits into from

Conversation

siddharthkp
Copy link
Member

@siddharthkp siddharthkp commented Mar 24, 2025

Note

Current status: main is failing integration tests, so need to run integration tests again once that is cleared up

Note: This PR does not include radio icons for single selection in a modal

Features:

Adding variant=modal does 3 things

  1. Changes the position to be in the center of the screen
  2. Makes onCancel a required prop
  3. Adds a backdrop, when you click the backdrop (click-outside), we call onCancel

Shortcut

We are still using AnchoredOverlay underneath. But, for variant=modal, we override its position by directly passing top, left, etc. to overlayProps going down to the Overlay

The ideal super clean solution would have been to refactor SelectPanel and conditionally use useAnchoredPosition instead of AnchoredOverlay for variant=anchored. Something I did attempt in #5230 earlier but had to revert.

This shortcut is easier to implement and touches less surface area.

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

@siddharthkp siddharthkp self-assigned this Mar 24, 2025
Copy link

changeset-bot bot commented Mar 24, 2025

🦋 Changeset detected

Latest commit: 973ebab

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 Minor

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 github-actions bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Mar 24, 2025
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!

@@ -143,6 +143,13 @@
{
"name": "sx",
"type": "SystemStyleObject"
},
{
"name": "data-responsive",
Copy link
Member Author

@siddharthkp siddharthkp Mar 26, 2025

Choose a reason for hiding this comment

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

Note for reviewer: I'm basically opening up an API to make Overlay responsive (fullscreen on narrow screens)

Should we call this responsiveVariant instead to make it feel more official? Or keep it subtle for now?

It only supports one value "fullscreen" and Overlay does not have variant so it does follow our object variant pattern 🤔 { narrow: 'fullscreen', regular: 'auto', wide: 'auto' } feels a bit odd.

Especially because Overlay is usually used by another component that passes it position props like top and left like AnchoredOverlay

Copy link
Member

Choose a reason for hiding this comment

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

I don't feel strongly either way, I don't see why not make it public though 👀

@@ -103,15 +103,6 @@ const StyledOverlay = toggleStyledComponent(
max-width: calc(100vw - 2rem);
}

&:where([data-variant='fullscreen']) {
Copy link
Member Author

@siddharthkp siddharthkp Mar 26, 2025

Choose a reason for hiding this comment

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

Note for reviewer: Overlay's css module is in GA, so we don't need this css in sx anymore

Copy link
Member

Choose a reason for hiding this comment

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

I think let's keep this for now just in case, in theory the ga FF could still be turned off at any moment? The team can remove this when they remove the FF entirely from this component 🙏

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought we weren't adding adding css for new features? Based on #5761 (comment)

I recently added this css in #5759, so thought I'll clean it up as well. yay/nay?

Copy link
Member

Choose a reason for hiding this comment

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

yeah I think the issue here is the styles won't be added at all because if FF is not enabled the Overlay classname will not be added so these styles will never make it in (why you need that FF on that other test), the correct way of adding new features without sx styling is to always have it go to css modules, for example if you created a separate class and added it to both (enabled, not enabled) implementations

Copy link
Contributor

github-actions bot commented Mar 26, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 105.49 KB (+0.14% 🔺)
packages/react/dist/browser.umd.js 105.82 KB (+0.13% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-5817 March 26, 2025 22:20 Inactive
@github-actions github-actions bot requested a deployment to storybook-preview-5817 March 26, 2025 22:25 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-5817 March 26, 2025 22:39 Inactive
margin: 0;
border-radius: unset;
&:where([data-responsive='fullscreen']) {
@media screen and (--viewportRange-narrow) {
Copy link
Member Author

@siddharthkp siddharthkp Mar 27, 2025

Choose a reason for hiding this comment

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

Note for reviewer: I changed full screen to only be a responsive thing instead of variant you can apply whenever. data-variantdata-responsive

@@ -459,6 +464,16 @@ export function SelectPanel({
role: 'dialog',
'aria-labelledby': titleId,
'aria-describedby': subtitle ? subtitleId : undefined,
...(variant === 'modal'
? {
/* override AnchoredOverlay position */
Copy link
Member Author

Choose a reason for hiding this comment

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

Note for reviewer: This is where all the shame lies. We are still using an AnchoredOverlay, but then we override it's position by directly passing top, left, etc to overlayProps going down

Copy link
Member

Choose a reason for hiding this comment

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

fair

Copy link
Contributor

@hectahertz hectahertz Apr 3, 2025

Choose a reason for hiding this comment

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

I'd rather us have branching on the container component instead of doing this, as it semantically is much harder to understand. I think it's fine for now, but definitely worth improving.

Copy link
Member

Choose a reason for hiding this comment

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

^ @hectahertz do we have an idea on the effort to do branching off the get go? I agree with you and we do have a bit of leeway time-wise with this, wondering if we can get it in 👀

@primer-integration
Copy link

🔴 golden-jobs completed with status failure.

@siddharthkp siddharthkp marked this pull request as ready for review March 28, 2025 21:50
@siddharthkp siddharthkp requested review from a team as code owners March 28, 2025 21:50
@hectahertz
Copy link
Contributor

hectahertz commented Apr 3, 2025

This should be complete now, refer to my commit history for all the changes and features added.

Visuals and behavior for the radio buttons on the single select modal variant:

Screen.Recording.2025-04-03.at.17.24.37.mov

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.

Some small suggestion/requests on the codebase. I wasn't able to test the UI since there's not a deployment available yet. I think you need to solve the merge conflicts @hectahertz

@hectahertz
Copy link
Contributor

Continued in #5883

@hectahertz hectahertz closed this Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: failing Changes in this PR cause breaking changes in gh/gh staff Author is a staff member update snapshots
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants