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

[pull] trunk from WordPress:trunk #74

Merged
merged 9 commits into from
Dec 10, 2024
5 changes: 3 additions & 2 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ concurrency:

jobs:
test:
runs-on: macos-12
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
runs-on: macos-13
if: false
#if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
matrix:
native-test-name: [gutenberg-editor-rendering]
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ concurrency:

jobs:
test:
runs-on: macos-12
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
runs-on: macos-13
if: false
#if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
matrix:
xcode: ['14.2']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalItemGroup as ItemGroup,
__experimentalItem as Item,
__experimentalHStack as HStack,
__experimentalZStack as ZStack,
__experimentalDropdownContentWrapper as DropdownContentWrapper,
Button,
MenuGroup,
ColorIndicator,
DuotonePicker,
Expand Down Expand Up @@ -189,15 +189,12 @@ export default function FiltersPanel( {

return (
<ItemGroup isBordered isSeparated>
<Button
__next40pxDefaultSize
{ ...toggleProps }
>
<Item as="button" { ...toggleProps }>
<LabeledColorIndicator
indicator={ duotone }
label={ __( 'Duotone' ) }
/>
</Button>
</Item>
</ItemGroup>
);
} }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function BlockTypesTab(
continue;
}

if ( rootClientId && item.isAllowedInCurrentRoot ) {
if ( item.isAllowedInCurrentRoot ) {
itemsForCurrentRoot.push( item );
} else {
itemsRemaining.push( item );
Expand Down
50 changes: 26 additions & 24 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1586,14 +1586,14 @@ export function getTemplateLock( state, rootClientId ) {
* @param {string|Object} blockNameOrType The block type object, e.g., the response
* from the block directory; or a string name of
* an installed block type, e.g.' core/paragraph'.
* @param {Set} checkedBlocks Set of block names that have already been checked.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {boolean} Whether the given block type is allowed to be inserted.
*/
const isBlockVisibleInTheInserter = (
state,
blockNameOrType,
checkedBlocks = new Set()
rootClientId = null
) => {
let blockType;
let blockName;
Expand Down Expand Up @@ -1621,26 +1621,19 @@ const isBlockVisibleInTheInserter = (
return false;
}

if ( checkedBlocks.has( blockName ) ) {
return false;
}

checkedBlocks.add( blockName );

// If parent blocks are not visible, child blocks should be hidden too.
if ( Array.isArray( blockType.parent ) ) {
return blockType.parent.some(
( name ) =>
( blockName !== name &&
isBlockVisibleInTheInserter(
state,
name,
checkedBlocks
) ) ||
// Exception for blocks with post-content parent,
// the root level is often consider as "core/post-content".
// This exception should only apply to the post editor ideally though.
name === 'core/post-content'
const parents = (
Array.isArray( blockType.parent ) ? blockType.parent : []
).concat( Array.isArray( blockType.ancestor ) ? blockType.ancestor : [] );
if ( parents.length > 0 ) {
const rootBlockName = getBlockName( state, rootClientId );
// This is an exception to the rule that says that all blocks are visible in the inserter.
// Blocks that require a given parent or ancestor are only visible if we're within that parent.
return (
parents.includes( 'core/post-content' ) ||
parents.includes( rootBlockName ) ||
getBlockParentsByBlockName( state, rootClientId, parents ).length >
0
);
}

Expand All @@ -1665,7 +1658,7 @@ const canInsertBlockTypeUnmemoized = (
blockName,
rootClientId = null
) => {
if ( ! isBlockVisibleInTheInserter( state, blockName ) ) {
if ( ! isBlockVisibleInTheInserter( state, blockName, rootClientId ) ) {
return false;
}

Expand Down Expand Up @@ -2072,6 +2065,7 @@ const buildBlockTypeItem =
category: blockType.category,
keywords: blockType.keywords,
parent: blockType.parent,
ancestor: blockType.ancestor,
variations: inserterVariations,
example: blockType.example,
utility: 1, // Deprecated.
Expand Down Expand Up @@ -2169,7 +2163,11 @@ export const getInserterItems = createRegistrySelector( ( select ) =>
} else {
blockTypeInserterItems = blockTypeInserterItems
.filter( ( blockType ) =>
isBlockVisibleInTheInserter( state, blockType )
isBlockVisibleInTheInserter(
state,
blockType,
rootClientId
)
)
.map( ( blockType ) => ( {
...blockType,
Expand Down Expand Up @@ -2501,7 +2499,11 @@ export const __experimentalGetAllowedPatterns = createRegistrySelector(
name,
rootClientId
)
: isBlockVisibleInTheInserter( state, name )
: isBlockVisibleInTheInserter(
state,
name,
rootClientId
)
)
);

Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3324,7 +3324,7 @@ describe( 'selectors', () => {
settings: {},
blockEditingModes: new Map(),
};
expect( canInsertBlocks( state, [ '2', '3' ], '1' ) ).toBe( true );
expect( canInsertBlocks( state, [ '2' ], '1' ) ).toBe( true );
} );

it( 'should deny blocks', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ class="wp-lightbox-overlay zoom"
data-wp-on-async--click="actions.hideLightbox"
data-wp-on-async-window--resize="callbacks.setOverlayStyles"
data-wp-on-async-window--scroll="actions.handleScroll"
data-wp-bind--style="state.overlayStyles"
tabindex="-1"
>
<button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button">
Expand All @@ -306,7 +307,6 @@ class="wp-lightbox-overlay zoom"
</figure>
</div>
<div class="scrim" style="background-color: $background_color" aria-hidden="true"></div>
<style data-wp-text="state.overlayStyles"></style>
</div>
HTML;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/image/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ const { state, actions, callbacks } = store(
// adding 1 pixel to the container width and height solves the problem,
// though this can be removed if the issue is fixed in the future.
state.overlayStyles = `
:root {
--wp--lightbox-initial-top-position: ${ screenPosY }px;
--wp--lightbox-initial-left-position: ${ screenPosX }px;
--wp--lightbox-container-width: ${ containerWidth + 1 }px;
Expand All @@ -352,8 +351,7 @@ const { state, actions, callbacks } = store(
--wp--lightbox-scrollbar-width: ${
window.innerWidth - document.documentElement.clientWidth
}px;
}
`;
`;
},
setButtonStyles() {
const { imageId } = getContext();
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
### Bug Fixes

- `ResizableBox`: Make drag handles focusable ([#67305](https://github.com/WordPress/gutenberg/pull/67305)).
- `CustomSelectControl`: Update correctly when `showSelectedHint` is enabled ([#67733](https://github.com/WordPress/gutenberg/pull/67733)).

## 28.13.0 (2024-11-27)

Expand Down
Loading
Loading