-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Dropdown: anchor popover to the dropdown wrapper (instead of the toggle) #43377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2a04ef5
7b5114b
f16c7be
f5facc6
a56b549
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,15 +18,27 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1 | |
| margin-right: auto; | ||
| } | ||
|
|
||
| .components-custom-gradient-picker__insert-point { | ||
| .components-custom-gradient-picker__control-point-dropdown { | ||
| position: absolute; | ||
| height: $grid-unit-20; | ||
| width: $grid-unit-20; | ||
| top: $components-custom-gradient-picker__padding; | ||
| // Trim any internal white spacing that would be cause d by inline positioned elements | ||
| display: flex; | ||
| } | ||
|
|
||
| .components-custom-gradient-picker__insert-point-dropdown { | ||
| position: relative; | ||
|
|
||
| // Same size as the .components-custom-gradient-picker__control-point-dropdown parent | ||
| height: inherit; | ||
| width: inherit; | ||
| min-width: $grid-unit-20; | ||
| border-radius: 50%; | ||
|
|
||
| background: $white; | ||
| padding: 2px; | ||
| top: $components-custom-gradient-picker__padding; | ||
| min-width: $grid-unit-20; | ||
| width: $grid-unit-20; | ||
| height: $grid-unit-20; | ||
| position: relative; | ||
|
|
||
| color: $gray-900; | ||
|
|
||
| svg { | ||
|
|
@@ -36,12 +48,11 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1 | |
| } | ||
|
|
||
| .components-custom-gradient-picker__control-point-button { | ||
| // Same size as the .components-custom-gradient-picker__control-point-dropdown parent | ||
| height: inherit; | ||
| width: inherit; | ||
| border-radius: 50%; | ||
| height: $grid-unit-20; | ||
| width: $grid-unit-20; | ||
| padding: 0; | ||
| position: absolute; | ||
| top: $components-custom-gradient-picker__padding; | ||
|
|
||
| // Shadow and stroke. | ||
| box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white, 0 0 $border-width-focus 0 rgba($black, 0.25); | ||
|
|
@@ -66,7 +77,6 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1 | |
| .components-custom-gradient-picker__inserter { | ||
| /*rtl:ignore*/ | ||
| direction: ltr; | ||
| width: 100%; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was not necessary anymore, since |
||
| } | ||
|
|
||
| .components-custom-gradient-picker__liner-gradient-indicator { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ export default function Dropdown( props ) { | |
| popoverProps, | ||
| onClose, | ||
| onToggle, | ||
| style, | ||
| } = props; | ||
| const containerRef = useRef(); | ||
| const [ isOpen, setIsOpen ] = useObservableState( false, onToggle ); | ||
|
|
@@ -95,6 +96,7 @@ export default function Dropdown( props ) { | |
| // clicked. Making this div focusable ensures such UAs will focus | ||
| // it and `closeIfFocusOutside` can tell if the toggle was clicked. | ||
| tabIndex="-1" | ||
| style={ style } | ||
| > | ||
| { renderToggle( args ) } | ||
| { isOpen && ( | ||
|
|
@@ -108,11 +110,7 @@ export default function Dropdown( props ) { | |
| // This value is used to ensure that the dropdowns | ||
| // align with the editor header by default. | ||
| offset={ 13 } | ||
| anchorRef={ | ||
| ! hasAnchorRef | ||
| ? containerRef?.current?.firstChild // Anchor to the rendered toggle. | ||
| : undefined | ||
| } | ||
|
Comment on lines
-111
to
-115
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main change that introduces the fix |
||
| anchorRef={ ! hasAnchorRef ? containerRef : undefined } | ||
| { ...popoverProps } | ||
| className={ classnames( | ||
| 'components-dropdown__content', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.