Skip to content

Commit

Permalink
Position the color popover properly
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 4, 2022
1 parent 05bed24 commit 10665a1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
16 changes: 0 additions & 16 deletions packages/block-editor/src/components/colors-gradients/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,6 @@
}
}

@include break-medium() {
.block-editor-panel-color-gradient-settings__dropdown-content {
.components-popover__content {
margin-right: #{ math.div($sidebar-width, 2) + $grid-unit-20 } !important;
}

&.is-from-top .components-popover__content {
margin-top: #{ -($grid-unit-60 + $grid-unit-15) } !important;
}

&.is-from-bottom .components-popover__content {
margin-bottom: #{ -($grid-unit-60 + $grid-unit-15) } !important;
}
}
}

.block-editor-panel-color-gradient-settings__dropdown:last-child > div {
border-bottom-width: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export default function ToolsPanelColorDropdown( {
className="block-editor-tools-panel-color-gradient-settings__item"
>
<Dropdown
popoverProps={ {
placement: 'left-start',
offset: 36,
} }
className="block-editor-tools-panel-color-dropdown"
contentClassName="block-editor-panel-color-gradient-settings__dropdown-content"
renderToggle={ ( { isOpen, onToggle } ) => (
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export default function Dropdown( props ) {
const {
renderContent,
renderToggle,
position = 'bottom right',
className,
contentClassName,
expandOnMobile,
headerTitle,
focusOnMount,
position,
popoverProps,
onClose,
onToggle,
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
shift,
autoUpdate,
arrow,
offset as offsetMiddleware,
} from '@floating-ui/react-dom';

/**
Expand Down Expand Up @@ -77,6 +78,7 @@ const Popover = (
isAlternate,
position,
placement = 'bottom-start',
offset,
focusOnMount = 'firstElement',
anchorRef,
anchorRect,
Expand All @@ -98,6 +100,7 @@ const Popover = (
? positionToPlacement( position )
: placement;
const middlewares = [
offset ? offsetMiddleware( offset ) : undefined,
__unstableForcePosition ? undefined : flip(),
shift( {
crossAxis: true,
Expand Down

0 comments on commit 10665a1

Please sign in to comment.