Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Align popover to bottom center of control point when in sidebar
  • Loading branch information
ciampo committed Aug 11, 2022
commit c0cf5d4a4699a327486bbaef06b7ab68053f90ec
5 changes: 3 additions & 2 deletions packages/components/src/color-palette/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ export function CustomColorPickerDropdown( {
} ) {
const popoverProps = {
__unstableShift: true,
// Open below the control point (centered aligned) when in the sidebar
...( isRenderedInSidebar
? {
placement: 'bottom-start',
offset: 20,
placement: 'bottom',
offset: 10,
}
: {} ),
...receivedPopoverProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ function GradientColorPickerDropdown( {
const result = {
className:
'components-custom-gradient-picker__color-picker-popover',
placement: 'top',
};
if ( isRenderedInSidebar ) {
result.anchorRef = gradientPickerDomRef;
result.placement = 'bottom-start';
if ( ! isRenderedInSidebar ) {
result.placement = 'top';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise it's a bit like this in trunk, but this line makes the duotone color picker look like this, overlapping the block toolbar:
Screen Shot 2022-08-09 at 12 50 18 pm

It might be good to simplify it and have GradientColorPickerDropdown always positioned underneath the control point. When there's not enough space Popover will already flip it to the top.

Would be good to get more thoughts on this from @jasmussen and possibly @ajlende.

Another note is that the useMemo here could be removed, as CustomColorPickerDropdown doesn't respect it and creates a new object on every render.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed 1d30a2a in which:

  • the placement is always set to bottom regardless of the isInSidebar prop (I also tweaked the offset by a couple of px)
  • I've used useMemo also inside CustomColorPickerDropdown (instead of removing it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, after 7c23528, there's currently no need for any popoverProps override (although there will probably be a need for it again soon)

}
return result;
}, [ gradientPickerDomRef, isRenderedInSidebar ] );
Expand Down