Skip to content

Commit

Permalink
Merge branch 'trunk' into rtlcss-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SmushyTaco committed Jan 15, 2025
2 parents 074b468 + 1623711 commit 6f67f14
Show file tree
Hide file tree
Showing 39 changed files with 188 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ Take, for example, this interactive block with two buttons and a paragraph:
<p id="status-paragraph" class="inactive" hidden>this is inactive</p>
</div>

<style>
.active {
color: green;
}
.inactive {
color: red;
}
</style>

<script>
const showHideBtn = document.getElementById( 'show-hide-btn' );
const activateBtn = document.getElementById( 'activate-btn' );
Expand Down Expand Up @@ -101,6 +110,15 @@ The declarative approach simplifies the process by focusing on _what_ should hap
this is inactive
</p>
</div>

<style>
.active {
color: green;
}
.inactive {
color: red;
}
</style>
```

```js
Expand Down
4 changes: 2 additions & 2 deletions lib/compat/wordpress-6.7/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function ( $registered_template ) use ( $template_files ) {
/**
* Hooks into `get_block_template` to add the `plugin` property when necessary.
*
* @param [WP_Block_Template|null] $block_template The found block template, or null if there isn’t one.
* @return [WP_Block_Template|null] The block template that was already found with the plugin property defined if it was registered by a plugin.
* @param WP_Block_Template|null $block_template The found block template, or null if there isn’t one.
* @return WP_Block_Template|null The block template that was already found with the plugin property defined if it was registered by a plugin.
*/
function _gutenberg_add_block_template_plugin_attribute( $block_template ) {
if ( $block_template ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/experimental/script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function gutenberg_filter_block_type_metadata_settings_register_view_module( $se
* @param string $field_name Field name to pick from metadata.
* @param int $index Optional. Index of the script to register when multiple items passed.
* Default 0.
* @return string Module ID.
* @return string|false Module ID.
*/
function gutenberg_register_block_module_id( $metadata, $field_name, $index = 0 ) {
if ( empty( $metadata[ $field_name ] ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
class="components-circular-option-picker__option-wrapper"
>
<button
aria-label="Color: red"
aria-label="red"
aria-selected="true"
class="components-button components-circular-option-picker__option is-next-40px-default-size"
data-active-item="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ $swatch-gap: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: calc(100% - ($button-size-next-default-40px + $grid-unit-05));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe( 'ColorPaletteControl', () => {
).toBeInTheDocument();

// Is showing the two predefined Colors.
expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
expect( screen.getAllByRole( 'option' ) ).toHaveLength( 2 );
} );

it( 'renders the color picker and does not render tabs if it is only possible to select a color', async () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ describe( 'ColorPaletteControl', () => {
).not.toBeInTheDocument();

// Is showing the two predefined Colors.
expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
expect( screen.getAllByRole( 'option' ) ).toHaveLength( 2 );
} );

it( 'renders the gradient picker and does not render tabs if it is only possible to select a gradient', async () => {
Expand Down
14 changes: 7 additions & 7 deletions packages/block-library/src/cover/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function setup( attributes, useCoreBlocks, customSettings ) {
async function createAndSelectBlock() {
await userEvent.click(
screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} )
);
await userEvent.click(
Expand All @@ -73,7 +73,7 @@ describe( 'Cover block', () => {
test( 'can set overlay color using color picker on block placeholder', async () => {
const { container } = await setup();
const colorPicker = screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} );
await userEvent.click( colorPicker );
const color = colorPicker.style.backgroundColor;
Expand All @@ -97,7 +97,7 @@ describe( 'Cover block', () => {

await userEvent.click(
screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} )
);

Expand Down Expand Up @@ -390,7 +390,7 @@ describe( 'Cover block', () => {
test( 'should toggle is-light class if background changed from light to dark', async () => {
await setup();
const colorPicker = screen.getByRole( 'option', {
name: 'Color: White',
name: 'White',
} );
await userEvent.click( colorPicker );

Expand All @@ -406,15 +406,15 @@ describe( 'Cover block', () => {
);
await userEvent.click( screen.getByText( 'Overlay' ) );
const popupColorPicker = screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} );
await userEvent.click( popupColorPicker );
expect( coverBlock ).not.toHaveClass( 'is-light' );
} );
test( 'should remove is-light class if overlay color is removed', async () => {
await setup();
const colorPicker = screen.getByRole( 'option', {
name: 'Color: White',
name: 'White',
} );
await userEvent.click( colorPicker );
const coverBlock = screen.getByLabelText( 'Block: Cover' );
Expand All @@ -429,7 +429,7 @@ describe( 'Cover block', () => {
// The default color is black, so clicking the black color option will remove the background color,
// which should remove the isDark setting and assign the is-light class.
const popupColorPicker = screen.getByRole( 'option', {
name: 'Color: White',
name: 'White',
} );
await userEvent.click( popupColorPicker );
expect( coverBlock ).not.toHaveClass( 'is-light' );
Expand Down
8 changes: 1 addition & 7 deletions packages/block-library/src/navigation-link/link-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function getSuggestionsQuery( type, kind ) {
}
}

function LinkUIBlockInserter( { clientId, onBack, onSelectBlock } ) {
function LinkUIBlockInserter( { clientId, onBack } ) {
const { rootBlockClientId } = useSelect(
( select ) => {
const { getBlockRootClientId } = select( blockEditorStore );
Expand Down Expand Up @@ -140,7 +140,6 @@ function LinkUIBlockInserter( { clientId, onBack, onSelectBlock } ) {
prioritizePatterns={ false }
selectBlockOnInsert
hasSearch={ false }
onSelect={ onSelectBlock }
/>
</div>
);
Expand Down Expand Up @@ -203,10 +202,6 @@ function UnforwardedLinkUI( props, ref ) {
`link-ui-link-control__description`
);

// Selecting a block should close the popover and also remove the (previously) automatically inserted
// link block so that the newly selected block can be inserted in its place.
const { onClose: onSelectBlock } = props;

return (
<Popover
ref={ ref }
Expand Down Expand Up @@ -287,7 +282,6 @@ function UnforwardedLinkUI( props, ref ) {
setAddingBlock( false );
setFocusAddBlockButton( true );
} }
onSelectBlock={ onSelectBlock }
/>
) }
</Popover>
Expand Down
79 changes: 60 additions & 19 deletions packages/block-library/src/query-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ import {
Warning,
HeadingLevelDropdown,
} from '@wordpress/block-editor';
import { ToggleControl, PanelBody } from '@wordpress/components';
import {
ToggleControl,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { __, _x, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { useArchiveLabel } from './use-archive-label';
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

const SUPPORTED_TYPES = [ 'archive', 'search' ];

Expand All @@ -36,6 +41,7 @@ export default function QueryTitleEdit( {
setAttributes,
} ) {
const { archiveTypeLabel, archiveNameLabel } = useArchiveLabel();
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

const TagName = `h${ level }`;
const blockProps = useBlockProps( {
Expand Down Expand Up @@ -89,16 +95,35 @@ export default function QueryTitleEdit( {
titleElement = (
<>
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () =>
setAttributes( {
showPrefix: true,
} )
}
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
hasValue={ () => ! showPrefix }
label={ __( 'Show archive type in title' ) }
onChange={ () =>
setAttributes( { showPrefix: ! showPrefix } )
onDeselect={ () =>
setAttributes( { showPrefix: true } )
}
checked={ showPrefix }
/>
</PanelBody>
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show archive type in title' ) }
onChange={ () =>
setAttributes( {
showPrefix: ! showPrefix,
} )
}
checked={ showPrefix }
/>
</ToolsPanelItem>
</ToolsPanel>
</InspectorControls>
<TagName { ...blockProps }>{ title }</TagName>
</>
Expand All @@ -109,18 +134,34 @@ export default function QueryTitleEdit( {
titleElement = (
<>
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () =>
setAttributes( {
showSearchTerm: true,
} )
}
>
<ToolsPanelItem
hasValue={ () => ! showSearchTerm }
label={ __( 'Show search term in title' ) }
onChange={ () =>
setAttributes( {
showSearchTerm: ! showSearchTerm,
} )
onDeselect={ () =>
setAttributes( { showSearchTerm: true } )
}
checked={ showSearchTerm }
/>
</PanelBody>
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show search term in title' ) }
onChange={ () =>
setAttributes( {
showSearchTerm: ! showSearchTerm,
} )
}
checked={ showSearchTerm }
/>
</ToolsPanelItem>
</ToolsPanel>
</InspectorControls>

<TagName { ...blockProps }>
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Bug Fixes

- `CircularOptionPicker`, `ColorPalette`: Fix usage of tooltip in the Circular option picker. ([#68602](https://github.com/WordPress/gutenberg/pull/68602)).
- `InputControl`: Ensures email and url inputs have consistent LTR alignment in RTL languages ([#68188](https://github.com/WordPress/gutenberg/pull/68188)).

## 29.1.0 (2025-01-02)
Expand Down
16 changes: 12 additions & 4 deletions packages/components/src/border-control/test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/**
* External dependencies
*/
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import {
fireEvent,
render,
screen,
waitFor,
within,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

/**
Expand Down Expand Up @@ -56,7 +62,7 @@ const getButton = ( name ) => {
};

const getColorOption = ( color ) => {
return screen.getByRole( 'option', { name: `Color: ${ color }` } );
return screen.getByRole( 'option', { name: `${ color }` } );
};

const queryButton = ( name ) => {
Expand Down Expand Up @@ -131,9 +137,11 @@ describe( 'BorderControl', () => {
await openPopover( user );

const customColorPicker = getButton( /Custom color picker/ );
const colorSwatchButtons = screen.getAllByRole( 'option', {
name: /^Color:/,
const circularOptionPicker = screen.getByRole( 'listbox', {
name: 'Custom color picker.',
} );
const colorSwatchButtons =
within( circularOptionPicker ).getAllByRole( 'option' );
const styleLabel = screen.getByText( 'Style' );
const solidButton = getButton( 'Solid' );
const dashedButton = getButton( 'Dashed' );
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/circular-option-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const Example = () => {
style={ { backgroundColor: color, color } }
isSelected={ index === currentColor }
onClick={ () => setCurrentColor( index ) }
aria-label={ name }
/>
);
} ) }
Expand Down Expand Up @@ -150,6 +149,6 @@ Inherits all of the [`Dropdown` props](/packages/components/src/dropdown/README.

Props for the underlying `Button` component.

Inherits all of the [`Button` props](/packages/components/src/button/README.md#props), except for `href`, `target`, and `children`.
Inherits all of the [`Button` props](/packages/components/src/button/README.md#props), except for `href`, `target`, and `children`.

- Required: No
Loading

0 comments on commit 6f67f14

Please sign in to comment.