Skip to content

Commit

Permalink
Avoid paint on popover when hovering content
Browse files Browse the repository at this point in the history
remove border on unstyled/expanded

use box-shadow instead of border

remove shadow on alternate

update changelog
  • Loading branch information
Corentin Gautier committed Dec 5, 2022
1 parent b4c3fba commit a365a85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- `BorderControl`, `ColorPicker` & `QueryControls`: Replace bottom margin overrides with `__nextHasNoMarginBottom` ([#45985](https://github.com/WordPress/gutenberg/pull/45985)).
- `CustomSelectControl`, `UnitControl`: Add `onFocus` and `onBlur` props ([#46096](https://github.com/WordPress/gutenberg/pull/46096)).
- `ResizableBox`: Prevent unnecessary paint on resize handles ([#46196](https://github.com/WordPress/gutenberg/pull/46196))
- `Popover`: Prevent unnecessary paint caused by using outline ([#46201](https://github.com/WordPress/gutenberg/pull/46201))

### Experimental

Expand Down
22 changes: 11 additions & 11 deletions packages/components/src/popover/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
$arrow-triangle-base-size: 14px;

$shadow-popover-border-default: 0 0 0 $border-width $gray-400;
$shadow-popover-border-default-alternate: 0 0 0 $border-width $gray-900;
$shadow-popover-border-top-only: 0 #{-$border-width} 0 0 $gray-400;
$shadow-popover-border-top-only-alternate: 0 #{-$border-width} 0 $gray-900;

.components-popover {
z-index: z-index(".components-popover");

Expand All @@ -15,26 +20,20 @@ $arrow-triangle-base-size: 14px;

.components-popover__content {
background: $white;
// Using outline instead of border to avoid impacting
// popover computations.
outline: $border-width solid $gray-400;
box-shadow: $shadow-popover;
box-shadow: $shadow-popover-border-default, $shadow-popover;
border-radius: $radius-block-ui;
box-sizing: border-box;
width: min-content;

// Alternate treatment for popovers that put them at elevation zero with high contrast.
.is-alternate & {
outline: $border-width solid $gray-900;
box-shadow: none;
box-shadow: $shadow-popover-border-default-alternate;
}

// A style that gives the popover no visible ui.
.is-unstyled & {
background: none;
border: none;
border-radius: 0;
outline: none;
box-shadow: none;
}

Expand All @@ -43,9 +42,10 @@ $arrow-triangle-base-size: 14px;
height: calc(100% - #{ $panel-header-height });
overflow-y: visible;
width: auto;
border: none;
outline: none;
border-top: $border-width solid $gray-900;
box-shadow: $shadow-popover-border-top-only;
}
.components-popover.is-expanded.is-alternate & {
box-shadow: $shadow-popover-border-top-only-alternate;
}
}

Expand Down

0 comments on commit a365a85

Please sign in to comment.