Skip to content

Commit

Permalink
Fix handling of zero css values in getCustomPropValue
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz committed Jan 30, 2024
1 parent 740a0aa commit 0b9b873
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions mu-plugins/blocks/sidebar-container/postcss/style.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

/* Account for local nav height on larger screens where it becomes fixed. */
@media (min-width: 890px) {
/* stylelint-disable-next-line length-zero-no-unit */
--local--nav--offset: 0px;
--local--nav--offset: 0;
--local--offset-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--wp--custom--local-navigation-bar--spacing--height, 60px));
}

Expand Down
3 changes: 3 additions & 0 deletions mu-plugins/blocks/sidebar-container/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const scrollHandlers = [];
*/
function getCustomPropValue( name, element = document.body ) {
const value = window.getComputedStyle( element ).getPropertyValue( name );
if ( '0' === value ) {
return 0;
}
if ( 'px' === value.slice( -2 ) ) {
return Number( value.replace( 'px', '' ) );
}
Expand Down

0 comments on commit 0b9b873

Please sign in to comment.