From 7e7d6cde00acadc45f7509853caeacc454c78fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 21 Jun 2022 16:03:14 +0200 Subject: [PATCH] Refactor: Reuse code of the editor placeholder across Post Comments and Post Comments Form (#40560) * Create a separate template for the Comments Form * Use the form in the Post Comments block * Add the missing "return" in the CommentForm --- .../src/post-comments-form/edit.js | 43 +++--------------- .../src/post-comments-form/form.js | 43 ++++++++++++++++++ .../block-library/src/post-comments/edit.js | 45 ++++--------------- 3 files changed, 57 insertions(+), 74 deletions(-) create mode 100644 packages/block-library/src/post-comments-form/form.js diff --git a/packages/block-library/src/post-comments-form/edit.js b/packages/block-library/src/post-comments-form/edit.js index 5fd73c11c7fdc..fbcd99d93f3f4 100644 --- a/packages/block-library/src/post-comments-form/edit.js +++ b/packages/block-library/src/post-comments-form/edit.js @@ -14,10 +14,11 @@ import { } from '@wordpress/block-editor'; import { useEntityProp } from '@wordpress/core-data'; import { __, sprintf } from '@wordpress/i18n'; -import { - __experimentalUseDisabled as useDisabled, - useInstanceId, -} from '@wordpress/compose'; + +/** + * Internal dependencies + */ +import CommentsForm from './form'; export default function PostCommentsFormEdit( { attributes, @@ -40,10 +41,6 @@ export default function PostCommentsFormEdit( { const isInSiteEditor = postType === undefined || postId === undefined; - const disabledFormRef = useDisabled(); - - const instanceId = useInstanceId( PostCommentsFormEdit ); - return ( <> @@ -76,35 +73,7 @@ export default function PostCommentsFormEdit( { ) } { ( 'open' === commentStatus || isInSiteEditor ) && ( -
-

{ __( 'Leave a Reply' ) }

-
-

- -