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

Core Data: Add entity prop locking and use it in the Site Title block. #18772

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Site Title Block: Use new `disabled` `RichText` prop.

  • Loading branch information
epiqueras committed Nov 27, 2019
commit 63378bf94c5a206cb309c97e3a38554a39eedab1
@@ -5,9 +5,9 @@ import {
useEntityProp,
__experimentalUseEntitySaving,
} from '@wordpress/core-data';
import { RichText } from '@wordpress/block-editor';
import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { Disabled, Button } from '@wordpress/components';
import { RichText } from '@wordpress/block-editor';

export default function SiteTitleEdit() {
const [ title, setTitle, titleIsLocked ] = useEntityProp(
@@ -21,15 +21,6 @@ export default function SiteTitleEdit() {
'title'
);

const input = (
<RichText
tagName="h1"
placeholder={ __( 'Site Title' ) }
value={ title }
onChange={ setTitle }
allowedFormats={ [] }
/>
);
return (
<>
<Button
@@ -41,7 +32,14 @@ export default function SiteTitleEdit() {
>
{ __( 'Update' ) }
</Button>
{ titleIsLocked ? <Disabled>{ input }</Disabled> : input }
<RichText
tagName="h1"
placeholder={ __( 'Site Title' ) }
value={ title }
onChange={ setTitle }
allowedFormats={ [] }
disabled={ titleIsLocked }
/>
</>
);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.