diff --git a/packages/edit-post/src/components/sidebar/post-schedule/index.js b/packages/edit-post/src/components/sidebar/post-schedule/index.js index f8b96fe6669e7..cf1c64fa79289 100644 --- a/packages/edit-post/src/components/sidebar/post-schedule/index.js +++ b/packages/edit-post/src/components/sidebar/post-schedule/index.js @@ -3,7 +3,7 @@ */ import { __, sprintf } from '@wordpress/i18n'; import { PanelRow, Dropdown, Button } from '@wordpress/components'; -import { useRef } from '@wordpress/element'; +import { useState } from '@wordpress/element'; import { PostSchedule as PostScheduleForm, PostScheduleCheck, @@ -11,13 +11,19 @@ import { } from '@wordpress/editor'; export default function PostSchedule() { - const anchorRef = useRef(); + // Use internal state instead of a ref to make sure that the component + // re-renders when the anchor's ref updates. + const [ popoverAnchor, setPopoverAnchor ] = useState( null ); + return ( - + { __( 'Publish' ) } { const postTypeSlug = select( editorStore ).getCurrentPostType(); @@ -46,10 +48,10 @@ export default function PostTemplate() { } return ( - + { __( 'Template' ) } - + { __( 'URL' ) } ( - + { __( 'Visibility' ) } { ! canEdit && ( @@ -31,7 +37,7 @@ export function PostVisibility() { // Anchor the popover to the middle of the // entire row so that it doesn't move around // when the label changes. - anchorRef: rowRef.current, + anchor: popoverAnchor, } } focusOnMount renderToggle={ ( { isOpen, onToggle } ) => (