Skip to content

Commit

Permalink
reduce cost of style calc+layout in --dialog-scrollgutter (#3144)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Ballard <[email protected]>
Co-authored-by: AdamShwert <[email protected]>
Co-authored-by: Arelia Jones <[email protected]>
Co-authored-by: Ariel Valentin <[email protected]>
Co-authored-by: Chris Gavin <[email protected]>
Co-authored-by: Cody Bodfield <[email protected]>
Co-authored-by: Daniel Colson <[email protected]>
Co-authored-by: Daniel Garman <[email protected]>
Co-authored-by: Dusty Greif <[email protected]>
Co-authored-by: Erinna Chen <[email protected]>
Co-authored-by: George Brocklehurst <[email protected]>
Co-authored-by: Jibran Garcia <[email protected]>
Co-authored-by: Jonathan Fuchs <[email protected]>
Co-authored-by: Kate Higa <[email protected]>
Co-authored-by: Manuel Puyol <[email protected]>
Co-authored-by: Matthew Costabile <[email protected]>
Co-authored-by: Matthew Reyes <[email protected]>
Co-authored-by: Melissa Pastore <[email protected]>
Co-authored-by: Ned Schwartz <[email protected]>
Co-authored-by: Phill MV <[email protected]>
Co-authored-by: Raffaele Di Fazio <[email protected]>
Co-authored-by: Sarah Vessels <[email protected]>
Co-authored-by: Simon Taranto <[email protected]>
  • Loading branch information
1 parent 7e7a60f commit 978e867
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-bananas-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Remove dialog-scrollgutter setting from hot-path, for improved performance
15 changes: 15 additions & 0 deletions app/components/primer/alpha/dialog.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@

/* Overlay */

/* The --dialog-scrollgutter property is used only on the body element to
* simulate scrollbar-gutter:stable. This property is not and should not
* be used elsewhere in the DOM. There is a performance penalty to
* setting inherited properties which can cause a large style recalc to
* occur, so it benefits us to prevent inheritance for this property.
* See https://web.dev/blog/at-property-performance
*/
@property --dialog-scrollgutter {
initial-value: 0;
inherits: false;
syntax: "<length>";
}

/* TODO: One day this can be :has(:modal), when it is better supported */
body.has-modal {
/* stylelint-disable-next-line csstools/value-no-unknown-custom-properties */
padding-right: var(--dialog-scrollgutter) !important;
overflow: hidden !important;
}
Expand Down Expand Up @@ -350,6 +364,7 @@ dialog.Overlay:not([open]) {
&:hover,
&:focus {
background-color: var(--button-default-bgColor-hover);
/* stylelint-disable-next-line primer/colors */
border: var(--borderWidth-thin) solid var(--control-bgColor-hover);
}

Expand Down

0 comments on commit 978e867

Please sign in to comment.