Skip to content

Commit

Permalink
Disable form element with useDisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz authored and ockham committed Apr 21, 2022
1 parent e78e57e commit 63cf602
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/block-library/src/post-comments-form/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@wordpress/block-editor';
import { useEntityProp } from '@wordpress/core-data';
import { __, sprintf } from '@wordpress/i18n';
import { __experimentalUseDisabled as useDisabled } from '@wordpress/compose';

export default function PostCommentsFormEdit( {
attributes,
Expand All @@ -36,6 +37,8 @@ export default function PostCommentsFormEdit( {

const isInSiteEditor = postType === undefined || postId === undefined;

const disabledFormRef = useDisabled();

return (
<>
<BlockControls group="block">
Expand Down Expand Up @@ -70,7 +73,11 @@ export default function PostCommentsFormEdit( {
{ ( 'open' === commentStatus || isInSiteEditor ) && (
<div className="wp-block-post-comments-form">
<h3>{ __( 'Leave a Reply' ) }</h3>
<form noValidate className="comment-form">
<form
noValidate
className="comment-form"
ref={ disabledFormRef }
>
<p>
<label htmlFor="comment">
{ __( 'Comment' ) }
Expand All @@ -81,7 +88,6 @@ export default function PostCommentsFormEdit( {
name="comment"
cols="45"
rows="8"
disabled
/>
</p>
<p>
Expand Down

0 comments on commit 63cf602

Please sign in to comment.