-
Notifications
You must be signed in to change notification settings - Fork 648
Add feature-flagged CSS containment to Overlay for rendering performance optimization #7424
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
base: main
Are you sure you want to change the base?
Conversation
|
Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
|
👋 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 |
|
|
||
| .Overlay { | ||
| position: absolute; | ||
| contain: layout style; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot we should use a feature flag to toggle a new class that contains these contain calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've refactored the implementation to use a feature flag:
- Created
.OverlayContainmentclass withcontain: layout style - Added
primer_react_overlay_css_containmentfeature flag (defaults tofalse) - Class is conditionally applied when flag is enabled
- Added tests to verify the feature flag behavior
Commit: 290a108
- Remove `contain: layout style` from `.Overlay` class - Add new `.OverlayContainment` class with `contain: layout style` - Add `primer_react_overlay_css_containment` feature flag - Conditionally apply `.OverlayContainment` class based on feature flag - Add tests to verify feature flag behavior Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
| height={height} | ||
| visibility={visibility} | ||
| data-responsive={responsiveVariant} | ||
| className={cssContainmentEnabled ? classes.OverlayContainment : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot should this be handled in BaseOverlay instead? and check the flag in that component so we properly pass className through
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to BaseOverlay! The feature flag check is now in BaseOverlay where className is applied, ensuring proper merging with user-provided classNames via clsx:
className={clsx(className, classes.Overlay, cssContainmentEnabled && classes.OverlayContainment)}This ensures any className passed through props is properly combined with the base classes.
Commit: 4e89bd1
- Move useFeatureFlag check from Overlay to BaseOverlay component - Ensures proper className merging with user-provided className via clsx - Removes duplicate className prop from Overlay component Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
|
@copilot are there snapshots / e2e tests we can use with the flag on to ensure the behavior/layout/style/paint are all correct |
- Add new test suite "with CSS containment feature flag" to Overlay e2e tests - Tests include visual regression (@vrt) and accessibility (@Aat) checks - All existing story variants are tested with the feature flag enabled - Screenshot filenames include ".with-containment" suffix for clarity - Tests ensure behavior/layout/style/paint are correct with containment Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
Added comprehensive e2e tests with the feature flag enabled! The new test suite includes: Visual Regression Tests (@vrt):
Accessibility Tests (@Aat):
This ensures behavior, layout, style, and paint are all correct with CSS containment applied. Commit: a4961a6 |
Adds
contain: layout styleto the Overlay component to isolate layout and style calculations within overlay boundaries, reducing browser work when overlay content changes. The implementation uses a feature flag for safe, opt-in rollout.Changes
CSS Module (
packages/react/src/Overlay/Overlay.module.css):Feature Flag (
packages/react/src/FeatureFlags/DefaultFeatureFlags.ts):primer_react_overlay_css_containment: falseflag (defaults to disabled)BaseOverlay Component (
packages/react/src/Overlay/Overlay.tsx):BaseOverlaycomponent usinguseFeatureFlag('primer_react_overlay_css_containment').OverlayContainmentclass is conditionally applied viaclsx(className, classes.Overlay, cssContainmentEnabled && classes.OverlayContainment)Unit Tests (
packages/react/src/Overlay/Overlay.test.tsx):E2E Tests (
e2e/components/Overlay.test.ts):.with-containmentsuffix for clarityPerformance Impact
When the feature flag is enabled:
Browser Support
CSS containment supported in Chrome 52+, Firefox 69+, Safari 15.4+, Edge 79+. Progressive enhancement—unsupported browsers ignore the property.
Changelog
New
primer_react_overlay_css_containmentfeature flag for opt-in CSS containment.OverlayContainmentCSS class withcontain: layout styleChanged
BaseOverlaycomponent to conditionally apply CSS containment based on feature flagBaseOverlayto ensure proper className merging with user-provided classNamesRollout strategy
Testing & Reviewing
Verify existing Overlay visual regression tests and functional behavior (positioning, focus management, click-outside) remain unchanged. The feature flag defaults to
false, so there is no behavior change until explicitly enabled. When enabled, the CSS containment property is a progressive enhancement with no breaking changes.The feature flag check is implemented in
BaseOverlayto properly handle className merging when users pass custom classNames through props.E2E tests with the feature flag enabled provide comprehensive verification across all story variants and themes, ensuring visual consistency, layout correctness, and accessibility compliance.
Merge checklist
Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.