Skip to content

Commit

Permalink
Notify editor of FSE dirty state by updating an arbitrary attribute (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Jun 18, 2019
1 parent 9fc1754 commit 4a5f380
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class SiteDescriptionEdit extends Component {

updateInitialDescription = () => this.setState( { initialDescription: this.state.description } );

handleUpdate( description ) {
const { setAttributes } = this.props;
this.setState( { description } );
setAttributes( { updated: Date.now() } );
}

render() {
const { className, noticeUI } = this.props;
const { description } = this.state;
Expand All @@ -68,7 +74,7 @@ class SiteDescriptionEdit extends Component {
<PlainText
className={ className }
value={ description }
onChange={ value => this.setState( { description: value } ) }
onChange={ value => this.handleUpdate( value ) }
placeholder={ __( 'Site Description' ) }
aria-label={ __( 'Site Description' ) }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ registerBlockType( 'a8c/site-description', {
reusable: false,
},
edit,
attributes: {
updated: {
default: null,
type: 'number',
},
},
save: () => null,
} );

0 comments on commit 4a5f380

Please sign in to comment.