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

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

SelectPanel: Add variant=modal #5817

wants to merge 19 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: d9640e3

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

@francinelucca francinelucca added the integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh label Mar 28, 2025
@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh labels Mar 28, 2025
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.

Mostly LGTM, just some questions/suggestions.

Was also wondering if you could elaborate on the feasibility of #5230? I see from the comments it was reverted due to failing integration checks, wondering how significant those were to warrant going this route. I'm ok with this solution, was just curious

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

&:where([data-variant='fullscreen']) {
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 🙏

@@ -143,6 +143,13 @@
{
"name": "sx",
"type": "SystemStyleObject"
},
{
"name": "data-responsive",
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 👀

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

Choose a reason for hiding this comment

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

fair

@siddharthkp
Copy link
Member Author

siddharthkp commented Mar 28, 2025

Was also wondering if you could elaborate on the feasibility of #5230? I see from the comments it was reverted due to failing integration checks, wondering how significant those were to warrant going this route. I'm ok with this solution, was just curious

It's definitely still feasible, but doesn't feel worth the effort anymore 🤔 I don't mind if the current solution stays long term too

@siddharthkp FYI these CI failures have nothing to do with this PR , #5802 (comment)

Thank you! I was about to debug

Copy link
Contributor

@emilybrick emilybrick left a comment

Choose a reason for hiding this comment

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

Hey! This looks good. Two minor things:

  • I think we should include the x icon here that does the same thing that onCancel would. This has always been the case in Figma. I know it may seem redundant, but I think the intent here is that it's expected behavior to have a close button in the top right of a modal dialog – in addition to the Cancel button in this case.
Screenshot 2025-03-28 at 2 01 17 PM

expected:
Screenshot 2025-03-28 at 3 18 14 PM

  • I discussed & confirmed w/ Primer design that the list items in the SelectPanel modal should use radios for single selection. Context
Screenshot 2025-03-28 at 3 18 08 PM

@siddharthkp
Copy link
Member Author

siddharthkp commented Mar 28, 2025

@emilybrick, Oops i only added the close icon button to the css module (feature flagged), not without it. Added it to both now!

<Box
sx={enabled ? undefined : {display: 'flex', flexDirection: 'column', height: 'inherit', maxHeight: 'inherit'}}
className={enabled ? classes.Wrapper : undefined}
<>
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: Recommend to review this with hide whitespace

@primer-integration
Copy link

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

@github-actions github-actions bot requested a deployment to storybook-preview-5817 March 28, 2025 20:54 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-5817 March 28, 2025 21:07 Inactive
@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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants