diff --git a/packages/components/src/higher-order/with-filters/index.js b/packages/components/src/higher-order/with-filters/index.js index 6c621c679b377..90625d74c3582 100644 --- a/packages/components/src/higher-order/with-filters/index.js +++ b/packages/components/src/higher-order/with-filters/index.js @@ -28,12 +28,14 @@ export default function withFilters( hookName ) { /** @inheritdoc */ constructor( props ) { super( props ); + this.ComponentProps = applyFilters( hookName + 'Props', props ); this.onHooksUpdated = this.onHooksUpdated.bind( this ); this.Component = applyFilters( hookName, OriginalComponent ); this.namespace = uniqueId( 'core/with-filters/component-' ); this.throttledForceUpdate = debounce( () => { this.Component = applyFilters( hookName, OriginalComponent ); + this.ComponentProps = applyFilters( hookName + 'Props', props ); this.forceUpdate(); }, ANIMATION_FRAME_PERIOD ); @@ -54,14 +56,14 @@ export default function withFilters( hookName ) { * @param {string} updatedHookName Name of the hook that was updated. */ onHooksUpdated( updatedHookName ) { - if ( updatedHookName === hookName ) { + if ( updatedHookName === hookName || updatedHookName === hookName + 'Props' ) { this.throttledForceUpdate(); } } /** @inheritdoc */ render() { - return ; + return ; } }; }, 'withFilters' ); diff --git a/packages/editor/src/components/post-publish-button/index.js b/packages/editor/src/components/post-publish-button/index.js index 3cd74e24e9f13..836fb36cdc853 100644 --- a/packages/editor/src/components/post-publish-button/index.js +++ b/packages/editor/src/components/post-publish-button/index.js @@ -6,7 +6,7 @@ import { noop, get } from 'lodash'; /** * WordPress dependencies */ -import { Button } from '@wordpress/components'; +import { Button, withFilters } from '@wordpress/components'; import { Component, createRef } from '@wordpress/element'; import { withSelect, withDispatch } from '@wordpress/data'; import { compose } from '@wordpress/compose'; @@ -102,4 +102,5 @@ export default compose( [ onSave: savePost, }; } ), + withFilters( 'editor.PostPublishButton' ), ] )( PostPublishButton ); diff --git a/packages/editor/src/components/post-publish-panel/toggle.js b/packages/editor/src/components/post-publish-panel/toggle.js index 3c8820cbba89d..1be2839091d3e 100644 --- a/packages/editor/src/components/post-publish-panel/toggle.js +++ b/packages/editor/src/components/post-publish-panel/toggle.js @@ -6,7 +6,7 @@ import { get } from 'lodash'; /** * WordPress Dependencies */ -import { Button } from '@wordpress/components'; +import { Button, withFilters } from '@wordpress/components'; import { compose } from '@wordpress/compose'; import { __ } from '@wordpress/i18n'; import { withSelect } from '@wordpress/data'; @@ -83,4 +83,5 @@ export default compose( [ postType: getCurrentPostType(), }; } ), + withFilters( 'editor.PostPublishPanelToggle' ), ] )( PostPublishPanelToggle );