Skip to content
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

WordPress 6.8 Compatibility: Replace ButtonGroup usage. #42627

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Split Button: Increase compatibility of components, preventing console warnings.
26 changes: 14 additions & 12 deletions projects/js-packages/components/components/split-button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ButtonGroup, Button, DropdownMenu } from '@wordpress/components';
import { Button, Flex, DropdownMenu } from '@wordpress/components';
import styles from './style.module.scss';
import { SplitButtonProps } from './types.js';
import type React from 'react';
Expand All @@ -22,17 +22,19 @@ const SplitButton: React.FC< SplitButtonProps > = ( {
...buttonProps
} ) => {
return (
<ButtonGroup className={ styles[ 'split-button' ] }>
<Button variant={ variant } { ...buttonProps } className={ styles.button } />
<DropdownMenu
toggleProps={ { variant, className: styles.button, ...toggleProps } }
popoverProps={ { noArrow: false, ...popoverProps } }
icon={ <DownIcon /> }
disableOpenOnArrowDown={ true }
controls={ controls }
label={ label }
/>
</ButtonGroup>
<Flex className={ styles[ 'split-button' ] }>
<div role="group" className="components-button-group">
<Button variant={ variant } { ...buttonProps } className={ styles.button } />
<DropdownMenu
toggleProps={ { variant, className: styles.button, ...toggleProps } }
popoverProps={ { noArrow: false, ...popoverProps } }
icon={ <DownIcon /> }
disableOpenOnArrowDown={ true }
controls={ controls }
label={ label }
/>
</div>
</Flex>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
height: var(--actions-size);
border-radius: var(--jp-border-radius);

:global(.components-button-group) {
display: flex;
height: 100%;
}

& > .button:first-child {
border-radius: var(--jp-border-radius) 0 0 var(--jp-border-radius);
}
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/replace-buttongroup-usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Map block: Increase compatibility of components, preventing console warnings.
41 changes: 22 additions & 19 deletions projects/plugins/jetpack/extensions/blocks/map/controls.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { BlockAlignmentToolbar, PanelColorSettings } from '@wordpress/block-editor';
import {
Button,
ButtonGroup,
ExternalLink,
PanelBody,
TextControl,
Expand All @@ -15,6 +13,10 @@ import {
Path,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalNumberControl as NumberControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControl as ToggleGroupControl,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import Locations from './locations';
Expand Down Expand Up @@ -181,23 +183,24 @@ export default ( {
value={ apiKeyControl }
onChange={ onKeyChange }
/>
<ButtonGroup>
<Button
type="button"
onClick={ updateAPIKey }
disabled={ ! apiKeyControl || apiKeyControl === apiKey }
>
{ __( 'Update Token', 'jetpack' ) }
</Button>
<Button
type="button"
onClick={ removeAPIKey }
disabled={ 'wpcom' === apiKeySource }
variant="secondary"
>
{ __( 'Remove Token', 'jetpack' ) }
</Button>
</ButtonGroup>
<div className="jetpack-map-token-settings">
<ToggleGroupControl isBlock __next40pxDefaultSize __nextHasNoMarginBottom>
<ToggleGroupControlOption
className="components-button jetpack-update-token-button"
label={ __( 'Update Token', 'jetpack' ) }
value="update"
onClick={ updateAPIKey }
disabled={ ! apiKeyControl || apiKeyControl === apiKey }
/>
<ToggleGroupControlOption
className="components-button is-secondary"
label={ __( 'Remove Token', 'jetpack' ) }
value="remove"
onClick={ removeAPIKey }
disabled={ 'wpcom' === apiKeySource }
/>
</ToggleGroupControl>
</div>
</PanelBody>
) : null }
</>
Expand Down
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/extensions/blocks/map/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const MapEdit = ( {
const { getSettings } = select( blockEditorStore );
const settings = getSettings();
return {
isPreviewMode: settings.__unstableIsPreviewMode,
isPreviewMode: settings.isPreviewMode,
};
}, [] );

Expand Down
23 changes: 23 additions & 0 deletions projects/plugins/jetpack/extensions/blocks/map/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,26 @@
}
}
}

.jetpack-map-token-settings {
.jetpack-update-token-button {
box-shadow: inset 0 0 0 1px #1e1e1e;
border-radius: 3px 0 0 2px;
}

.components-button.is-secondary {
border-radius: 0 2px 2px 0;
margin-left: -1px;
}

.components-toggle-group-control {
border: none;
outline: none;
box-shadow: none;

&:focus, &:focus-within {
outline: none;
box-shadow: none;
}
}
}
Loading