-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Reuse code of the editor placeholder across Post Comments a…
…nd 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
- Loading branch information
Showing
3 changed files
with
57 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
__experimentalUseDisabled as useDisabled, | ||
useInstanceId, | ||
} from '@wordpress/compose'; | ||
|
||
const CommentsForm = () => { | ||
const disabledFormRef = useDisabled(); | ||
const instanceId = useInstanceId( CommentsForm ); | ||
|
||
return ( | ||
<div className="comment-respond"> | ||
<h3 className="comment-reply-title">{ __( 'Leave a Reply' ) }</h3> | ||
<form noValidate className="comment-form" ref={ disabledFormRef }> | ||
<p> | ||
<label htmlFor={ `comment-${ instanceId }` }> | ||
{ __( 'Comment' ) } | ||
</label> | ||
<textarea | ||
id={ `comment-${ instanceId }` } | ||
name="comment" | ||
cols="45" | ||
rows="8" | ||
/> | ||
</p> | ||
<p className="form-submit wp-block-button"> | ||
<input | ||
name="submit" | ||
type="submit" | ||
className="submit wp-block-button__link" | ||
label={ __( 'Post Comment' ) } | ||
value={ __( 'Post Comment' ) } | ||
/> | ||
</p> | ||
</form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CommentsForm; |
This file contains 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