Skip to content
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

Components: Fix Post Publishing Popover moving when certain dates are clicked #30298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/components/src/panel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ The class that will be added with `components-panel__row`. to the classes of the
- Type: `String`
- Required: No

##### Ref

PanelRow accepts a forwarded ref that will be added to the wrapper div. Usage:

`<PanelRow className="edit-post-post-schedule" ref={ anchorRef }>`

---

#### PanelHeader
Expand Down
16 changes: 12 additions & 4 deletions packages/components/src/panel/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
*/
import classnames from 'classnames';

function PanelRow( { className, children } ) {
const classes = classnames( 'components-panel__row', className );
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';

return <div className={ classes }>{ children }</div>;
}
const PanelRow = forwardRef( ( { className, children }, ref ) => (
retrofox marked this conversation as resolved.
Show resolved Hide resolved
<div
className={ classnames( 'components-panel__row', className ) }
ref={ ref }
>
{ children }
</div>
) );

export default PanelRow;
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
*/
import { __ } from '@wordpress/i18n';
import { PanelRow, Dropdown, Button } from '@wordpress/components';
import { useRef } from '@wordpress/element';
import {
PostSchedule as PostScheduleForm,
PostScheduleLabel,
PostScheduleCheck,
} from '@wordpress/editor';

export function PostSchedule() {
const anchorRef = useRef();

return (
<PostScheduleCheck>
<PanelRow className="edit-post-post-schedule">
<PanelRow className="edit-post-post-schedule" ref={ anchorRef }>
<span>{ __( 'Publish' ) }</span>
<Dropdown
popoverProps={ { anchorRef: anchorRef.current } }
retrofox marked this conversation as resolved.
Show resolved Hide resolved
position="bottom left"
contentClassName="edit-post-post-schedule__dialog"
renderToggle={ ( { onToggle, isOpen } ) => (
Expand Down