Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use allowed formats in format types calculation
  • Loading branch information
fluiddot committed May 13, 2022
commit 0d388292d28563e8dfbfd6ce9d02f1c078cfba80
13 changes: 10 additions & 3 deletions packages/rich-text/src/component/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,10 +1252,17 @@ RichText.defaultProps = {
};

const withFormatTypes = ( WrappedComponent ) => ( props ) => {
const {
clientId,
identifier,
withoutInteractiveFormatting,
allowedFormats,
} = props;
const { formatTypes } = useFormatTypes( {
clientId: props.clientId,
identifier: props.identifier,
withoutInteractiveFormatting: props.withoutInteractiveFormatting,
clientId,
identifier,
withoutInteractiveFormatting,
allowedFormats,
Comment on lines +1256 to +1266
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out that the format types weren't taking into account the allowed formats calculated in the RichText component:

const adjustedAllowedFormats = getAllowedFormats( {
allowedFormats,
formattingControls,
disableFormats,
} );

This was causing that setting the prop __unstableDisableFormats doesn't hide the text color format button from the toolbar, as well as preventing hiding other format buttons when using the allowedFormats prop.

} );

return <WrappedComponent { ...props } formatTypes={ formatTypes } />;
Expand Down