Skip to content

Commit

Permalink
Merge branch 'WordPress:trunk' into fix/datepicket-day-labels-uk-dts-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksVeter authored Dec 2, 2024
2 parents ee6229b + d8a457b commit 01b104a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions backport-changelog/6.8/7695.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ https://github.com/WordPress/wordpress-develop/pull/7695

* https://github.com/WordPress/gutenberg/pull/66631
* https://github.com/WordPress/gutenberg/pull/67465
* https://github.com/WordPress/gutenberg/pull/66579
* https://github.com/WordPress/gutenberg/pull/66654
18 changes: 13 additions & 5 deletions lib/compat/wordpress-6.8/preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@
*/
function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) {
if ( 'core/edit-site' === $context->name ) {
$post_id = null;
$post = null;
if ( isset( $_GET['postId'] ) && is_numeric( $_GET['postId'] ) ) {
$post_id = (int) $_GET['postId'];
$post = get_post( (int) $_GET['postId'] );
}
if ( isset( $_GET['p'] ) && preg_match( '/^\/page\/(\d+)$/', $_GET['p'], $matches ) ) {
$post_id = (int) $matches[1];
$post = get_post( (int) $matches[1] );
}

if ( $post_id ) {
$route_for_post = rest_get_route_for_post( $post_id );
if ( $post ) {
$route_for_post = rest_get_route_for_post( $post );
if ( $route_for_post ) {
$paths[] = add_query_arg( 'context', 'edit', $route_for_post );
if ( 'page' === $post->post_type ) {
$paths[] = add_query_arg(
'slug',
// @see https://github.com/WordPress/gutenberg/blob/489f6067c623926bce7151a76755bb68d8e22ea7/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js#L139-L140
'page-' . $post->post_name,
'/wp/v2/templates/lookup'
);
}
}
}

Expand Down
11 changes: 8 additions & 3 deletions packages/block-editor/src/components/iframe/use-scale-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
* WordPress dependencies
*/
import { useEffect, useRef, useCallback } from '@wordpress/element';
import { useReducedMotion, useResizeObserver } from '@wordpress/compose';
import {
usePrevious,
useReducedMotion,
useResizeObserver,
} from '@wordpress/compose';

/**
* @typedef {Object} TransitionState
Expand Down Expand Up @@ -280,14 +284,15 @@ export function useScaleCanvas( {
transitionFromRef.current = transitionToRef.current;
}, [ iframeDocument ] );

const previousIsZoomedOut = usePrevious( isZoomedOut );
/**
* Runs when zoom out mode is toggled, and sets the startAnimation flag
* so the animation will start when the next useEffect runs. We _only_
* want to animate when the zoom out mode is toggled, not when the scale
* changes due to the container resizing.
*/
useEffect( () => {
if ( ! iframeDocument ) {
if ( ! iframeDocument || previousIsZoomedOut === isZoomedOut ) {
return;
}

Expand All @@ -300,7 +305,7 @@ export function useScaleCanvas( {
return () => {
iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
};
}, [ iframeDocument, isZoomedOut ] );
}, [ iframeDocument, isZoomedOut, previousIsZoomedOut ] );

/**
* This handles:
Expand Down

0 comments on commit 01b104a

Please sign in to comment.