Skip to content

Conversation

marissahuysentruyt
Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt commented Jun 26, 2025

Description

This work adds a container query to the .spectrum-Dialog element. The container query should allow fullscreen/fullscreenTakeover dialogs to reflow the content grid sooner. The ability to reflow sooner should be useful when implementations and users elect to add a component to the dialog's header area (i.e. the steplist in the fullscreen dialog example), allowing the dialog heading to fill up more space instead of wrapping so much, even on large-ish screens.

Because of the container query, however, extra containerStyles and wrapperStyles were added to the test canvases to make sure the entire dialog is captured, instead of just the minimum inline sizes.

Jira/Specs

CSS-1092

How and where has this been tested?

Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.

Jira/Specs

CSS-1092

Validation steps

  • Pull down the branch or visit the deploy preview. (@rise-erpelding)
  • Navigate to the dialog docs page. Verify nothing on that page has changed (you can compare to the spectrum-two preview).
  • Visit the full screen dialog story page.
  • In your browser, change the viewport size and verify that the fullscreen grid changes earlier for smaller screens, and allows the heading and extra header component to wrap as before.
  • Repeat this process for the full screen takeover dialog story.
  • If you remove the .spectrum-Dialog-headerContentWrapper element and its contents in your browser inspector, the dialog's heading fills all of its space.
  • For both full screen dialog variants, I'd love to get extra validation to make sure the original 700px media query isn't interfering with the 864px container query.

Additional validation

  • The dialog tests return no VRT diffs

Regression testing

Validate:

  1. The documentation pages for at least two other components are still loading, including:
  • The pages render correctly, are accessible, and are responsive.
  1. If components have been modified, VRTs have been run on this branch:
  • VRTs have been run and looked at.
  • Any VRT changes have been accepted (by reviewer and/or PR author), or there are no changes.

Screenshots

🚫 Before (820px)

Screenshot 2025-07-01 at 9 41 37 AM

✅ After (also 820px)

Screenshot 2025-07-01 at 9 44 31 AM

To-do list

@marissahuysentruyt marissahuysentruyt self-assigned this Jun 26, 2025
Copy link

changeset-bot bot commented Jun 26, 2025

🦋 Changeset detected

Latest commit: 9a94096

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

This PR includes changesets to release 3 packages
Name Type
@spectrum-css/dialog Minor
@spectrum-css/bundle Patch
@spectrum-css/preview 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

@marissahuysentruyt marissahuysentruyt added size-2 S ~6-18hrs; not hard or time consuming, one or two work days to complete. wip This is a work in progress, don't judge. S2 Spectrum 2 labels Jun 26, 2025
Copy link
Contributor

github-actions bot commented Jun 26, 2025

File metrics

Summary

Total size: 1.43 MB*

Package Size Minified Gzipped
dialog 16.64 KB 15.91 KB 2.30 KB

dialog

Filename Head Minified Gzipped Compared to base
index.css 16.64 KB 15.91 KB 2.30 KB 🔴 ⬆ 0.28 KB
metadata.json 6.58 KB - - -
* Size is the sum of all main files for packages in the library.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

Copy link
Contributor

github-actions bot commented Jun 26, 2025

📚 Branch preview

PR #4000 has been deployed to Azure Blob Storage: https://spectrumcss.z13.web.core.windows.net/pr-4000/index.html.

@marissahuysentruyt marissahuysentruyt changed the title Marissahuysentruyt/css 1092 dialog header flexibility refactor(dialog): add more header flexibility Jun 26, 2025
@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1092-dialog-header-flexibility branch from cb5d59b to a2205c6 Compare June 27, 2025 21:12
@marissahuysentruyt marissahuysentruyt removed the wip This is a work in progress, don't judge. label Jul 1, 2025
Comment on lines 71 to 74
"width": "100%", // forces the data-inner-container to be full width so the container query doesn't break.
},
containerStyles: {
"width": "100%", // forces the data-outer-container to be full width so the container query doesn't break.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without the width: 100%, the dialogs were defaulting to their minimum widths because of the container query. This forces these test containers to be the full width, so the fullscreen dialogs can appropriately be their full widths.

Screenshot 2025-07-01 at 9 04 52 AM

Copy link
Collaborator

@rise-erpelding rise-erpelding Jul 1, 2025

Choose a reason for hiding this comment

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

Oh noes! I believe it's the first one (the inner-container) that's creating a horizontal scrollbar at the bottom in the default story (but not the test):

image

I did play with it for a bit and something like -webkit-fill-available does work rather than 100%, but doesn't work in Firefox.

We could also try using isChromatic for this? I don't know if it's cool to use that for components. But it'd look something like

import isChromatic from "chromatic/isChromatic";

// all the other stuff...

wrapperStyles: isChromatic ? {
		"background-color": "var(--spectrum-gray-50)",
		"width": "100%", // forces the data-inner-container to be full width so the container query doesn't break.
	} : {},

// ...all the rest of the stuff

There might be a better solution than that also!

Ok and one more thing on this: would we want to refactor to use inline-size instead of width? I know using logical properties for the storybook wrapper styles is a little less critical than in the styles we ship, so I definitely don't consider that blocking at all.

@marissahuysentruyt marissahuysentruyt added the run_vrt For use on PRs looking to kick off VRT label Jul 1, 2025
@marissahuysentruyt marissahuysentruyt marked this pull request as ready for review July 1, 2025 13:22
@rise-erpelding rise-erpelding self-requested a review July 1, 2025 17:22
Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

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

I left only a few comments, but they're lengthy! The container query works great as far as I can see, just left a comment about the margin-block-end on the heading.

I also noted a small issue with the horizontal scrolling in Storybook, otherwise though, this looks fantastic!

}

.spectrum-Dialog-heading {
margin-block-end: var(--spectrum-standard-dialog-spacing-title-to-description);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want a mod here? var(--mod-standard-dialog-spacing-title-to-description, var(--spectrum-standard-dialog-spacing-title-to-description))? I guess this was just moved up from below though maybe?

Although maybe more importantly, am I missing the spot where this would take effect? I think this might be taken over by the margin-block-end: 0 in the container query in every case 🤔
image

Or maybe we don't need this? You've already got a nice gap between the heading and the header content wrapper, and the header has its own margin-block-end that would provide space between the it and the dialog content if the header content wrapper wasn't there.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We still need this! This margin-block-end gets added for the default dialogs when the grid layout changes in smaller screens:

Screenshot 2025-07-07 at 12 24 27 PM

I wasn't going to add a mod, only because it wasn't there before, but that mod already exists, so I don't see a problem adding it here.

Comment on lines 71 to 74
"width": "100%", // forces the data-inner-container to be full width so the container query doesn't break.
},
containerStyles: {
"width": "100%", // forces the data-outer-container to be full width so the container query doesn't break.
Copy link
Collaborator

@rise-erpelding rise-erpelding Jul 1, 2025

Choose a reason for hiding this comment

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

Oh noes! I believe it's the first one (the inner-container) that's creating a horizontal scrollbar at the bottom in the default story (but not the test):

image

I did play with it for a bit and something like -webkit-fill-available does work rather than 100%, but doesn't work in Firefox.

We could also try using isChromatic for this? I don't know if it's cool to use that for components. But it'd look something like

import isChromatic from "chromatic/isChromatic";

// all the other stuff...

wrapperStyles: isChromatic ? {
		"background-color": "var(--spectrum-gray-50)",
		"width": "100%", // forces the data-inner-container to be full width so the container query doesn't break.
	} : {},

// ...all the rest of the stuff

There might be a better solution than that also!

Ok and one more thing on this: would we want to refactor to use inline-size instead of width? I know using logical properties for the storybook wrapper styles is a little less critical than in the styles we ship, so I definitely don't consider that blocking at all.

@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1092-dialog-header-flexibility branch from ced82f0 to 00bcbe5 Compare July 7, 2025 16:30
Comment on lines +72 to +75
...(showTestingGrid && { "inline-size": "100%" }), // Applies conditional styles based on showTestingGrid- forces the data-inner-container to be full width so the container query doesn't break.
},
containerStyles: {
...(showTestingGrid && { "inline-size": "100%" }), // forces the data-outer-container to be full width so the container query doesn't break.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rise-erpelding What do you think about this approach instead? I didn't notice the horizontal scroll before, but I believe it's gone now everywhere. Let me know!

Copy link
Contributor

@5t3ph 5t3ph left a comment

Choose a reason for hiding this comment

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

🎉 great work!

@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1092-dialog-header-flexibility branch from 00bcbe5 to 9a94096 Compare July 10, 2025 14:42
@marissahuysentruyt marissahuysentruyt merged commit f654c8d into spectrum-two Jul 10, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review run_vrt For use on PRs looking to kick off VRT S2 Spectrum 2 size-2 S ~6-18hrs; not hard or time consuming, one or two work days to complete.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants