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

RichText: add disabled prop #18792

Merged
merged 1 commit into from Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/block-editor/src/components/rich-text/index.js
Expand Up @@ -350,6 +350,7 @@ class RichTextWrapper extends Component {
reversed,
style,
preserveWhiteSpace,
disabled,
// From experimental filter. To do: pick props instead.
...experimentalProps
} = this.props;
Expand Down Expand Up @@ -400,6 +401,7 @@ class RichTextWrapper extends Component {
__unstableUndo={ undo }
style={ style }
preserveWhiteSpace={ preserveWhiteSpace }
disabled={ disabled }
>
{ ( { isSelected, value, onChange, Editable } ) =>
<>
Expand Down
6 changes: 4 additions & 2 deletions packages/rich-text/src/component/index.js
Expand Up @@ -1024,6 +1024,7 @@ class RichText extends Component {
className,
placeholder,
forwardedRef,
disabled,
} = this.props;
const ariaProps = pickBy( this.props, ( value, key ) =>
startsWith( key, 'aria-' ) );
Expand Down Expand Up @@ -1057,8 +1058,9 @@ class RichText extends Component {
onKeyUp={ this.onSelectionChange }
onMouseUp={ this.onSelectionChange }
onTouchEnd={ this.onSelectionChange }
contentEditable
suppressContentEditableWarning
// Do not set the attribute if disabled.
contentEditable={ disabled ? undefined : true }
suppressContentEditableWarning={ ! disabled }
/>
);
}
Expand Down