Skip to content

Commit

Permalink
Add calc for top output to support non-zero offsets that factor in th…
Browse files Browse the repository at this point in the history
…e logged in admin bar height
  • Loading branch information
andrewserong committed Oct 31, 2022
1 parent 6cbb5e1 commit 1b8e1b5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,13 @@ function gutenberg_get_layout_position_style( $selector, $style ) {
'top' === $side &&
( 'fixed' === $position_type || 'sticky' === $position_type )
) {
// TODO: wrap the following value in a `calc()` + `$side_value`,
// so that any included value is treated as an offset.
$side_value = 'var(--wp-admin--admin-bar--height, 0px)';
// Ensure 0 values can be used in `calc()` calculations.
if ( '0' === $side_value || 0 === $side_value ) {
$side_value = '0px';
}

// Ensure current side value also factors in the height of the logged in admin bar.
$side_value = "calc($side_value + var(--wp-admin--admin-bar--height, 0px))";
}

$position_styles[] =
Expand Down

0 comments on commit 1b8e1b5

Please sign in to comment.