-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Edit Post: use Popover's new anchor prop #43808
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
Merged
ciampo
merged 5 commits into
refactor/popover-new-anchor-prop
from
refactor/edit-post-new-anchor-popover-prop
Sep 6, 2022
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aec1629
Edit Post: use Popover s new anchor prop
ciampo 1ea0fb0
Update comment
ciampo 07ed3b2
SImplify code
ciampo 562e23c
Update packages/edit-post/src/components/sidebar/post-schedule/index.js
ciampo 1e3184a
Allow passing a `null` anchor
ciampo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Edit Post: use Popover s new anchor prop
- Loading branch information
commit aec162994b3a81b5ffa806e466a2dbb7eac08655
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,21 +3,31 @@ | |
| */ | ||
| import { __, sprintf } from '@wordpress/i18n'; | ||
| import { PanelRow, Dropdown, Button } from '@wordpress/components'; | ||
| import { useRef } from '@wordpress/element'; | ||
| import { useCallback, useState } from '@wordpress/element'; | ||
| import { | ||
| PostSchedule as PostScheduleForm, | ||
| PostScheduleCheck, | ||
| usePostScheduleLabel, | ||
| } 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 then anchor's ref updates. | ||
| const [ popoverAnchor, setPopoverAnchor ] = useState(); | ||
| const rowCallbackRef = useCallback( ( node ) => { | ||
|
||
| // Fall back to `undefined` in case the ref is `null`. | ||
| setPopoverAnchor( node ?? undefined ); | ||
| }, [] ); | ||
|
|
||
| return ( | ||
| <PostScheduleCheck> | ||
| <PanelRow className="edit-post-post-schedule" ref={ anchorRef }> | ||
| <PanelRow | ||
| className="edit-post-post-schedule" | ||
| ref={ rowCallbackRef } | ||
| > | ||
| <span>{ __( 'Publish' ) }</span> | ||
| <Dropdown | ||
| popoverProps={ { anchorRef } } | ||
| popoverProps={ { anchor: popoverAnchor } } | ||
| position="bottom left" | ||
| contentClassName="edit-post-post-schedule__dialog" | ||
| focusOnMount | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.