Skip to content

Commit

Permalink
prep build 03/25
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Mar 25, 2024
2 parents 7f2d708 + 3229569 commit 5e3393f
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 50 deletions.
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/block-mover/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const BlockMoverButton = forwardRef(
? clientIds
: [ clientIds ];
const blocksCount = normalizedClientIds.length;
const { disabled } = props;

const {
blockType,
Expand Down Expand Up @@ -98,7 +99,9 @@ const BlockMoverButton = forwardRef(

return {
blockType: block ? getBlockType( block.name ) : null,
isDisabled: direction === 'up' ? isFirstBlock : isLastBlock,
isDisabled:
disabled ||
( direction === 'up' ? isFirstBlock : isLastBlock ),
rootClientId: blockRootClientId,
firstIndex: firstBlockIndex,
isFirst: isFirstBlock,
Expand Down
9 changes: 8 additions & 1 deletion packages/block-editor/src/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import BlockDraggable from '../block-draggable';
import { BlockMoverUpButton, BlockMoverDownButton } from './button';
import { store as blockEditorStore } from '../../store';

function BlockMover( { clientIds, hideDragHandle } ) {
function BlockMover( {
clientIds,
hideDragHandle,
isBlockMoverUpButtonDisabled,
isBlockMoverDownButtonDisabled,
} ) {
const { canMove, rootClientId, isFirst, isLast, orientation } = useSelect(
( select ) => {
const {
Expand Down Expand Up @@ -83,6 +88,7 @@ function BlockMover( { clientIds, hideDragHandle } ) {
<ToolbarItem>
{ ( itemProps ) => (
<BlockMoverUpButton
disabled={ isBlockMoverUpButtonDisabled }
clientIds={ clientIds }
{ ...itemProps }
/>
Expand All @@ -91,6 +97,7 @@ function BlockMover( { clientIds, hideDragHandle } ) {
<ToolbarItem>
{ ( itemProps ) => (
<BlockMoverDownButton
disabled={ isBlockMoverDownButtonDisabled }
clientIds={ clientIds }
{ ...itemProps }
/>
Expand Down
28 changes: 28 additions & 0 deletions packages/block-editor/src/components/block-preview/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,31 @@
bottom: 0;
z-index: 1;
}

// Restrict these shadows to the context of the inspector.
.interface-interface-skeleton__sidebar {
.block-editor-block-patterns-list__list-item {
.block-editor-block-preview__container {
box-shadow: 0 0 $border-width rgba($black, 0.1);
}
&:hover {
.block-editor-block-preview__container {
box-shadow: 0 0 0 2px $gray-900;
}
}
}
}

// Restrict these shadows to the context of the inserter.
.editor-inserter-sidebar {
.block-editor-block-patterns-list__list-item {
.block-editor-block-preview__container {
box-shadow: 0 15px 25px rgb(0 0 0 / 7%);
}
&:hover {
.block-editor-block-preview__container {
box-shadow: 0 0 0 2px $gray-900, 0 15px 25px rgb(0 0 0 / 7%);
}
}
}
}
4 changes: 3 additions & 1 deletion packages/block-editor/src/components/block-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ export const BlockSwitcher = ( { clientIds, disabled } ) => {
if ( ! _blocks.length || _blocks.some( ( block ) => ! block ) ) {
return { invalidBlocks: true };
}
const rootClientId = getBlockRootClientId( clientIds );
const rootClientId = getBlockRootClientId(
Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds
);
const [ { name: firstBlockName } ] = _blocks;
const _isSingleBlockSelected = _blocks.length === 1;
const blockType = getBlockType( firstBlockName );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
hasBlockMovingClientId,
getBlockListSettings,
__unstableGetEditorMode,
getNextBlockClientId,
getPreviousBlockClientId,
} = select( blockEditorStore );
const { getActiveBlockVariation, getBlockType } =
select( blocksStore );
Expand All @@ -69,6 +71,26 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
const orientation =
getBlockListSettings( rootClientId )?.orientation;
const match = getActiveBlockVariation( name, attributes );
const isBlockTemplatePart =
blockType?.name === 'core/template-part';

let isNextBlockTemplatePart = false;
const nextClientId = getNextBlockClientId();
if ( nextClientId ) {
const { name: nextName } = getBlock( nextClientId );
const nextBlockType = getBlockType( nextName );
isNextBlockTemplatePart =
nextBlockType?.name === 'core/template-part';
}

let isPrevBlockTemplatePart = false;
const prevClientId = getPreviousBlockClientId();
if ( prevClientId ) {
const { name: prevName } = getBlock( prevClientId );
const prevBlockType = getBlockType( prevName );
isPrevBlockTemplatePart =
prevBlockType?.name === 'core/template-part';
}

return {
blockMovingMode: hasBlockMovingClientId(),
Expand All @@ -80,11 +102,22 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
index + 1,
orientation
),
isBlockTemplatePart,
isNextBlockTemplatePart,
isPrevBlockTemplatePart,
};
},
[ clientId, rootClientId ]
);
const { label, icon, blockMovingMode, editorMode } = selected;
const {
label,
icon,
blockMovingMode,
editorMode,
isBlockTemplatePart,
isNextBlockTemplatePart,
isPrevBlockTemplatePart,
} = selected;
const { setNavigationMode, removeBlock } = useDispatch( blockEditorStore );
const ref = useRef();

Expand Down Expand Up @@ -252,8 +285,17 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
<BlockIcon icon={ icon } showColors />
</FlexItem>
<FlexItem>
{ editorMode === 'zoom-out' && (
<BlockMover clientIds={ [ clientId ] } hideDragHandle />
{ editorMode === 'zoom-out' && ! isBlockTemplatePart && (
<BlockMover
clientIds={ [ clientId ] }
hideDragHandle
isBlockMoverUpButtonDisabled={
isPrevBlockTemplatePart
}
isBlockMoverDownButtonDisabled={
isNextBlockTemplatePart
}
/>
) }
{ editorMode === 'navigation' && (
<BlockDraggable clientIds={ [ clientId ] }>
Expand Down
11 changes: 0 additions & 11 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,6 @@ $block-inserter-tabs-height: 44px;
}
}

.block-editor-block-patterns-list__list-item {
.block-editor-block-preview__container {
box-shadow: 0 15px 25px rgb(0 0 0 / 7%);
}
&:hover {
.block-editor-block-preview__container {
box-shadow: 0 0 0 2px $gray-900, 0 15px 25px rgb(0 0 0 / 7%);
}
}
}

.block-editor-inserter__patterns-category-panel {
padding: 0 $grid-unit-20;
display: flex;
Expand Down
8 changes: 8 additions & 0 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,14 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
return $post;
}

/**
* Skip meta generation when consumers intentionally update specific Navigation fields
* and omit the content update.
*/
if ( ! isset( $post->post_content ) ) {
return $post;
}

/*
* We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
* all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
Expand Down
13 changes: 11 additions & 2 deletions packages/block-library/src/navigation/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,20 @@ const { state, actions } = store(
// Only open on hover if the overlay is closed.
Object.values( overlayOpenedBy || {} ).filter( Boolean )
.length === 0
)
) {
actions.openMenu( 'hover' );
}
},
closeMenuOnHover() {
actions.closeMenu( 'hover' );
const { type, overlayOpenedBy } = getContext();
if (
type === 'submenu' &&
// Only close on hover if the overlay is closed.
Object.values( overlayOpenedBy || {} ).filter( Boolean )
.length === 0
) {
actions.closeMenu( 'hover' );
}
},
openMenuOnClick() {
const ctx = getContext();
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/social-links/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
.wp-block-social-links .wp-block-social-links__social-prompt {
min-height: $button-size-small;
list-style: none;
order: 2; // Move after the appender button. Because this element is non-interactive, it does not affect tab order.

// Show as block UI.
font-family: $default-font;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export default function TemplatePartEdit( {
( partsAsPatterns.length > 0 ||
blockPatterns.length > 0 ) && (
<InspectorControls>
<PanelBody title={ __( 'Replace' ) }>
<PanelBody title={ __( 'Design' ) }>
<TemplatesList
availableTemplates={ partsAsPatterns }
onSelect={ ( pattern ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,10 @@ describe.each( [
await sleep();
await press.Tab();
expect( currentSelectedItem ).toHaveFocus();
expect( currentSelectedItem ).toHaveTextContent( 'violets' );

await type( 'aq' );
// Ideally we would test a multi-character typeahead, but anything more than a single character is flaky
await type( 'a' );

expect(
screen.queryByRole( 'listbox', {
Expand All @@ -398,8 +400,10 @@ describe.each( [
} )
).not.toBeInTheDocument();

// This Enter is a workaround for flakiness, and shouldn't be necessary in an actual browser
await press.Enter();
expect( currentSelectedItem ).toHaveTextContent( 'aquamarine' );

expect( currentSelectedItem ).toHaveTextContent( 'amber' );
} );

it( 'Should have correct aria-selected value for selections', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ describe.each( [
await sleep();
await press.Tab();
expect( currentSelectedItem ).toHaveFocus();
expect( currentSelectedItem ).toHaveTextContent( 'violets' );

await type( 'aq' );
// Ideally we would test a multi-character typeahead, but anything more than a single character is flaky
await type( 'a' );

expect(
screen.queryByRole( 'listbox', {
Expand All @@ -185,8 +187,10 @@ describe.each( [
} )
).not.toBeInTheDocument();

// This Enter is a workaround for flakiness, and shouldn't be necessary in an actual browser
await press.Enter();
expect( currentSelectedItem ).toHaveTextContent( 'aquamarine' );

expect( currentSelectedItem ).toHaveTextContent( 'amber' );
} );

it( 'Should have correct aria-selected value for selections', async () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,6 @@
line-height: $grid-unit-20;

.dataviews-view-list__field {
margin: 0;

&:has(.dataviews-view-list__field-value:empty) {
display: none;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/view-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function ListItem( {
id={ descriptionId }
>
{ visibleFields.map( ( field ) => (
<p
<div
key={ field.id }
className="dataviews-view-list__field"
>
Expand All @@ -111,7 +111,7 @@ function ListItem( {
<span className="dataviews-view-list__field-value">
{ field.render( { item } ) }
</span>
</p>
</div>
) ) }
</div>
</VStack>
Expand Down
32 changes: 11 additions & 21 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,27 +377,17 @@ export default function PagePages() {
);

const [ showAddPageModal, setShowAddPageModal ] = useState( false );
const openModal = useCallback( () => {
if ( ! showAddPageModal ) {
setShowAddPageModal( true );
}
}, [ showAddPageModal ] );
const closeModal = useCallback( () => {
if ( showAddPageModal ) {
setShowAddPageModal( false );
}
}, [ showAddPageModal ] );
const handleNewPage = useCallback(
( { type, id } ) => {
history.push( {
postId: id,
postType: type,
canvas: 'edit',
} );
closeModal();
},
[ history ]
);

const openModal = () => setShowAddPageModal( true );
const closeModal = () => setShowAddPageModal( false );
const handleNewPage = ( { type, id } ) => {
history.push( {
postId: id,
postType: type,
canvas: 'edit',
} );
closeModal();
};

// TODO: we need to handle properly `data={ data || EMPTY_ARRAY }` for when `isLoading`.
return (
Expand Down
1 change: 1 addition & 0 deletions packages/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ protected static function get_classnames( $style_value, $style_definition ) {
foreach ( $style_definition['classnames'] as $classname => $property_key ) {
if ( true === $property_key ) {
$classnames[] = $classname;
continue;
}

$slug = static::get_slug_from_preset_value( $style_value, $property_key );
Expand Down

0 comments on commit 5e3393f

Please sign in to comment.