Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/remove-period-from-settings-panel-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Infinite-Null committed Feb 28, 2025
2 parents 02271c7 + 18a4c0d commit 582a514
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 90 deletions.
1 change: 0 additions & 1 deletion packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@
}

&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: $dark-gray-placeholder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import PatternExplorerSidebar from './pattern-explorer-sidebar';
import PatternList from './pattern-list';
import { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';

function PatternsExplorer( { initialCategory, rootClientId } ) {
function PatternsExplorer( { initialCategory, rootClientId, onModalClose } ) {
const [ searchValue, setSearchValue ] = useState( '' );
const [ selectedCategory, setSelectedCategory ] = useState(
initialCategory?.name
Expand All @@ -34,6 +34,7 @@ function PatternsExplorer( { initialCategory, rootClientId } ) {
selectedCategory={ selectedCategory }
patternCategories={ patternCategories }
rootClientId={ rootClientId }
onModalClose={ onModalClose }
/>
</div>
);
Expand All @@ -46,7 +47,7 @@ function PatternsExplorerModal( { onModalClose, ...restProps } ) {
onRequestClose={ onModalClose }
isFullScreen
>
<PatternsExplorer { ...restProps } />
<PatternsExplorer onModalClose={ onModalClose } { ...restProps } />
</Modal>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function PatternList( {
selectedCategory,
patternCategories,
rootClientId,
onModalClose,
} ) {
const container = useRef();
const debouncedSpeak = useDebounce( speak, 500 );
Expand Down Expand Up @@ -152,7 +153,10 @@ function PatternList( {
<>
<BlockPatternsList
blockPatterns={ pagingProps.categoryPatterns }
onClickPattern={ onClickPattern }
onClickPattern={ ( pattern, blocks ) => {
onClickPattern( pattern, blocks );
onModalClose();
} }
isDraggable={ false }
/>
<BlockPatternsPaging { ...pagingProps } />
Expand Down
6 changes: 6 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

## Unreleased

### Documentation

- `FontSizePicker`: Fix Storybook units control type to use `inline-check` and improve documentation clarifying unitless mode in `README.md` ([#68936](https://github.com/WordPress/gutenberg/pull/68936)).

### Bug Fixes

- `TextControl`: Ensures email and url inputs have consistent LTR alignment in RTL languages ([#68561](https://github.com/WordPress/gutenberg/pull/68561)).
- `InputControl`: Ensure consistent placeholder color ([#69334](https://github.com/WordPress/gutenberg/pull/69334)).

### Enhancement

- `TextareaControl`: Fix Firefox placeholder text opacity override ([#69312](https://github.com/WordPress/gutenberg/pull/69312)).
- `BorderControlDropdown`, `BorderControl`: Reset button is always visible. ([#69066](https://github.com/WordPress/gutenberg/pull/69066)).

### Internal
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/font-size-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Available units for custom font size selection.

The current font size value.

**Note**: For the `units` property to work, the current font size value must be specified as strings with units (e.g., `'12px'` instead of `12`). When the font size is provided as a number, the component operates in "unitless mode" where the `units` property has no effect.

- Required: No

### `withReset`: `boolean`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const meta: Meta< typeof FontSizePicker > = {
component: FontSizePicker,
argTypes: {
value: { control: false },
units: {
control: 'inline-check',
options: [ 'px', 'em', 'rem', 'vw', 'vh' ],
},
},
parameters: {
actions: { argTypesRegex: '^on.*' },
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/font-size-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export type FontSizePickerProps = {
units?: string[];
/**
* The current font size value.
*
* Note: For the `units` property to work, the current font size value must be specified
* as strings with units (e.g., '12px' instead of 12). When the font size is provided
* as a number, the component operates in "unitless mode" where the `units` property has no effect.
*/
value?: number | string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,15 @@ export const Input = styled.input< InputProps >`
${ customPaddings }
&::-webkit-input-placeholder {
line-height: normal;
color: ${ COLORS.ui.darkGrayPlaceholder };
}
&::-moz-placeholder {
color: ${ COLORS.ui.darkGrayPlaceholder };
}
&:-ms-input-placeholder {
color: ${ COLORS.ui.darkGrayPlaceholder };
}
&[type='email'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export const StyledTextarea = styled.textarea`
}
&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: ${ COLORS.ui.darkGrayPlaceholder };
}
Expand All @@ -76,7 +75,6 @@ export const StyledTextarea = styled.textarea`
}
&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: ${ COLORS.ui.lightGrayPlaceholder };
}
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-site/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
.edit-site-sidebar__screen-wrapper {
padding: 0;
}

.edit-site-sidebar-navigation-screen__main {
padding: 0 $grid-unit-15;
}
}

.edit-site-layout__canvas-container {
Expand Down
38 changes: 22 additions & 16 deletions packages/editor/src/components/document-outline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { useDispatch, useSelect } from '@wordpress/data';
import { useRef } from '@wordpress/element';
import { useRef, useMemo } from '@wordpress/element';
import { create, getTextContent } from '@wordpress/rich-text';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as coreStore } from '@wordpress/core-data';
Expand Down Expand Up @@ -83,16 +83,13 @@ function EmptyOutlineIllustration() {
* @return {Array} An array of heading blocks enhanced with the properties described above.
*/
const computeOutlineHeadings = ( blocks = [] ) => {
return blocks.flatMap( ( block = {} ) => {
if ( block.name === 'core/heading' ) {
return {
...block,
level: block.attributes.level,
isEmpty: isEmptyHeading( block ),
};
}
return computeOutlineHeadings( block.innerBlocks );
} );
return blocks
.filter( ( block ) => block.name === 'core/heading' )
.map( ( block ) => ( {
...block,
level: block.attributes.level,
isEmpty: isEmptyHeading( block ),
} ) );
};

const isEmptyHeading = ( heading ) =>
Expand All @@ -113,22 +110,31 @@ export default function DocumentOutline( {
hasOutlineItemsDisabled,
} ) {
const { selectBlock } = useDispatch( blockEditorStore );
const { blocks, title, isTitleSupported } = useSelect( ( select ) => {
const { getBlocks } = select( blockEditorStore );
const { title, isTitleSupported } = useSelect( ( select ) => {
const { getEditedPostAttribute } = select( editorStore );
const { getPostType } = select( coreStore );
const postType = getPostType( getEditedPostAttribute( 'type' ) );

return {
title: getEditedPostAttribute( 'title' ),
blocks: getBlocks(),
isTitleSupported: postType?.supports?.title ?? false,
};
} );
const blocks = useSelect( ( select ) => {
const { getClientIdsWithDescendants, getBlock } =
select( blockEditorStore );
const clientIds = getClientIdsWithDescendants();
// Note: Don't modify data inside the `Array.map` callback,
// all compulations should happen in `computeOutlineHeadings`.
return clientIds.map( ( id ) => getBlock( id ) );
} );

const prevHeadingLevelRef = useRef( 1 );

const headings = computeOutlineHeadings( blocks );
const headings = useMemo(
() => computeOutlineHeadings( blocks ),
[ blocks ]
);

if ( headings.length < 1 ) {
return (
<div className="editor-document-outline has-no-headings">
Expand Down
56 changes: 19 additions & 37 deletions packages/editor/src/components/post-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,39 @@ import { usePostActions } from './actions';

const { Menu, kebabCase } = unlock( componentsPrivateApis );

function useEditedEntityRecordsWithPermissions( postType, postIds ) {
const { items, permissions } = useSelect(
export default function PostActions( { postType, postId, onActionPerformed } ) {
const [ activeModalAction, setActiveModalAction ] = useState( null );

const { item, permissions } = useSelect(
( select ) => {
const { getEditedEntityRecord, getEntityRecordPermissions } =
unlock( select( coreStore ) );
return {
items: postIds.map( ( postId ) =>
getEditedEntityRecord( 'postType', postType, postId )
),
permissions: postIds.map( ( postId ) =>
getEntityRecordPermissions( 'postType', postType, postId )
item: getEditedEntityRecord( 'postType', postType, postId ),
permissions: getEntityRecordPermissions(
'postType',
postType,
postId
),
};
},
[ postIds, postType ]
[ postId, postType ]
);

return useMemo( () => {
return items.map( ( item, index ) => ( {
const itemWithPermissions = useMemo( () => {
return {
...item,
permissions: permissions[ index ],
} ) );
}, [ items, permissions ] );
}

export default function PostActions( { postType, postId, onActionPerformed } ) {
const [ activeModalAction, setActiveModalAction ] = useState( null );
const _postIds = useMemo( () => {
if ( Array.isArray( postId ) ) {
return postId;
}
return postId ? [ postId ] : [];
}, [ postId ] );

const itemsWithPermissions = useEditedEntityRecordsWithPermissions(
postType,
_postIds
);
permissions,
};
}, [ item, permissions ] );
const allActions = usePostActions( { postType, onActionPerformed } );

const actions = useMemo( () => {
return allActions.filter( ( action ) => {
return (
( ! action.isEligible ||
itemsWithPermissions.some( ( itemWithPermissions ) =>
action.isEligible( itemWithPermissions )
) ) &&
( itemsWithPermissions.length < 2 || action.supportsBulk )
! action.isEligible || action.isEligible( itemWithPermissions )
);
} );
}, [ allActions, itemsWithPermissions ] );
}, [ allActions, itemWithPermissions ] );

return (
<>
Expand All @@ -90,15 +72,15 @@ export default function PostActions( { postType, postId, onActionPerformed } ) {
<Menu.Popover>
<ActionsDropdownMenuGroup
actions={ actions }
items={ itemsWithPermissions }
items={ [ itemWithPermissions ] }
setActiveModalAction={ setActiveModalAction }
/>
</Menu.Popover>
</Menu>
{ !! activeModalAction && (
<ActionModal
action={ activeModalAction }
items={ itemsWithPermissions }
items={ [ itemWithPermissions ] }
closeModal={ () => setActiveModalAction( null ) }
/>
) }
Expand Down
12 changes: 7 additions & 5 deletions packages/editor/src/components/post-card-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ export default function PostCardPanel( {
<Badge>{ pageTypeBadge }</Badge>
) }
</Text>
<PostActions
postType={ postType }
postId={ postId }
onActionPerformed={ onActionPerformed }
/>
{ postIds.length === 1 && (
<PostActions
postType={ postType }
postId={ postIds[ 0 ] }
onActionPerformed={ onActionPerformed }
/>
) }
</HStack>
{ postIds.length > 1 && (
<Text className="editor-post-card-panel__description">
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/components/post-text-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ textarea.editor-post-text-editor {

&::-moz-placeholder {
color: $dark-gray-placeholder;
// Override Firefox default.
opacity: 1;
}

&:-ms-input-placeholder {
Expand Down
Loading

0 comments on commit 582a514

Please sign in to comment.