-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DropdownMenu: Deprecate 36px default size for toggle button #68329
base: button-deprecate-size
Are you sure you want to change the base?
Changes from all commits
b6e5376
19c8b1f
f9cd7fc
d0c4317
8e20d65
3d56175
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ exports[`BlockAlignmentUI should match snapshot when controls are hidden 1`] = ` | |
aria-expanded="false" | ||
aria-haspopup="true" | ||
aria-label="Align" | ||
class="components-button components-dropdown-menu__toggle has-icon" | ||
class="components-button components-dropdown-menu__toggle is-compact has-icon" | ||
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. |
||
data-toolbar-item="true" | ||
type="button" | ||
> | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -18,7 +18,7 @@ export function BlockSettingsMenu( { clientIds, ...props } ) { | |||
{ ( toggleProps ) => ( | ||||
<BlockSettingsDropdown | ||||
clientIds={ clientIds } | ||||
toggleProps={ toggleProps } | ||||
toggleProps={ { ...toggleProps, size: 'compact' } } | ||||
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. 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. In some instances, like here, we'll override the In others, we'll prioritize the user value:
Is there a reason for this discrepancy, and should we treat them consistently? |
||||
{ ...props } | ||||
/> | ||||
) } | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,6 +334,7 @@ export const BlockSwitcher = ( { clientIds } ) => { | |
} | ||
text={ blockIndicatorText } | ||
toggleProps={ { | ||
size: 'compact', | ||
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. |
||
description: blockSwitcherDescription, | ||
...toggleProps, | ||
} } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ exports[`BlockVerticalAlignmentUI should match snapshot when controls are hidden | |
aria-expanded="false" | ||
aria-haspopup="true" | ||
aria-label="Change vertical alignment" | ||
class="components-button components-dropdown-menu__toggle has-icon" | ||
class="components-button components-dropdown-menu__toggle is-compact has-icon" | ||
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. |
||
data-toolbar-item="true" | ||
type="button" | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import type { | |
DropdownOption, | ||
DropdownMenuInternalContext, | ||
} from './types'; | ||
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size'; | ||
|
||
function mergeProps< | ||
T extends { className?: string; [ key: string ]: unknown }, | ||
|
@@ -82,6 +83,17 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) { | |
} | ||
} | ||
|
||
if ( toggleProps?.as === undefined ) { | ||
maybeWarnDeprecated36pxSize( { | ||
componentName: 'DropdownMenu', | ||
__next40pxDefaultSize: toggleProps?.__next40pxDefaultSize, | ||
size: toggleProps?.size, | ||
feature: | ||
'36px default size for default toggle button in wp.components.DropdownMenu', | ||
hint: 'Set `toggleProps={ __next40pxDefaultSize: true }` to start opting into the new default size, which will become the default in a future version. For icon buttons, consider setting a non-default size like `toggleProps={ size: "compact" }`.', | ||
} ); | ||
} | ||
|
||
const mergedPopoverProps = mergeProps( | ||
{ | ||
className: 'components-dropdown-menu__popover', | ||
|
@@ -120,6 +132,9 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) { | |
return ( | ||
<Toggle | ||
{ ...mergedToggleProps } | ||
{ ...( toggleProps?.as === undefined | ||
? { __shouldNotWarnDeprecated36pxSize: true } | ||
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 to prevent a redundant warning from |
||
: {} ) } | ||
icon={ icon } | ||
onClick={ | ||
( ( event ) => { | ||
|
@@ -242,6 +257,7 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) { | |
* <DropdownMenu | ||
* icon={ more } | ||
* label="Select a direction" | ||
* toggleProps={ { size: 'compact' } } | ||
* controls={ [ | ||
* { | ||
* title: 'Up', | ||
|
@@ -276,7 +292,11 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) { | |
* import { more, arrowUp, arrowDown, trash } from '@wordpress/icons'; | ||
* | ||
* const MyDropdownMenu = () => ( | ||
* <DropdownMenu icon={ more } label="Select a direction"> | ||
* <DropdownMenu | ||
* icon={ more } | ||
* label="Select a direction" | ||
* toggleProps={ { size: 'compact' } } | ||
* > | ||
* { ( { onClose } ) => ( | ||
* <> | ||
* <MenuGroup> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,10 @@ function ToolbarDropdownMenu( | |
popoverProps={ { | ||
...props.popoverProps, | ||
} } | ||
toggleProps={ toolbarItemProps } | ||
toggleProps={ { | ||
size: 'compact', | ||
...toolbarItemProps, | ||
} } | ||
Comment on lines
+40
to
+43
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. |
||
/> | ||
) } | ||
</ToolbarItem> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ function ToolbarGroupCollapsed( { | |
controls={ controls } | ||
toggleProps={ { | ||
...internalToggleProps, | ||
size: 'compact', | ||
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. |
||
'data-toolbar-item': true, | ||
} } | ||
{ ...props } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.