Skip to content

Commit

Permalink
RichText: remove native props for web (#25700)
Browse files Browse the repository at this point in the history
* Fix passing native props

* Fix comment
  • Loading branch information
ellatrix committed Sep 29, 2020
1 parent d3b04b8 commit 363df9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
35 changes: 20 additions & 15 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ function RichTextWrapper(
multiline,
inlineToolbar,
wrapperClassName,
className,
autocompleters,
onReplace,
placeholder,
Expand All @@ -120,10 +119,6 @@ function RichTextWrapper(
__unstableOnSplitAtEnd: onSplitAtEnd,
__unstableOnSplitMiddle: onSplitMiddle,
identifier,
// To do: find a better way to implicitly inherit props.
start: startAttr,
reversed,
style,
preserveWhiteSpace,
__unstableEmbedURLOnPaste,
__unstableDisableFormats: disableFormats,
Expand Down Expand Up @@ -557,9 +552,6 @@ function RichTextWrapper(
selectionEnd={ selectionEnd }
onSelectionChange={ onSelectionChange }
tagName={ tagName }
className={ classnames( classes, className, {
'keep-placeholder-on-focus': keepPlaceholderOnFocus,
} ) }
placeholder={ placeholder }
allowedFormats={ adjustedAllowedFormats }
withoutInteractiveFormatting={ withoutInteractiveFormatting }
Expand All @@ -577,11 +569,8 @@ function RichTextWrapper(
__unstableDidAutomaticChange={ didAutomaticChange }
__unstableUndo={ undo }
__unstableDisableFormats={ disableFormats }
style={ style }
preserveWhiteSpace={ preserveWhiteSpace }
disabled={ disabled }
start={ startAttr }
reversed={ reversed }
unstableOnFocus={ unstableOnFocus }
__unstableAllowPrefixTransformations={
__unstableAllowPrefixTransformations
Expand Down Expand Up @@ -611,9 +600,11 @@ function RichTextWrapper(
maxWidth={ maxWidth }
onBlur={ onBlur }
setRef={ setRef }
// Destructuring the id prop before { ...props } doesn't work
// correctly on web https://github.com/WordPress/gutenberg/pull/25624
// Props to be set on the editable container are destructured on the
// element itself for web (see below), but passed through rich text
// for native.
id={ props.id }
style={ props.style }
>
{ ( {
isSelected: nestedIsSelected,
Expand Down Expand Up @@ -643,13 +634,27 @@ function RichTextWrapper(
<TagName
{ ...editableProps }
{ ...props }
style={
props.style
? {
...props.style,
...editableProps.style,
}
: editableProps.style
}
className={ classnames(
classes,
props.className,
editableProps.className,
{
'keep-placeholder-on-focus': keepPlaceholderOnFocus,
}
) }
aria-autocomplete={
listBoxId ? 'list' : undefined
}
aria-owns={ listBoxId }
aria-activedescendant={ activeId }
start={ startAttr }
reversed={ reversed }
onKeyDown={ ( event ) => {
onKeyDown( event );
editableProps.onKeyDown( event );
Expand Down
9 changes: 2 additions & 7 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import classnames from 'classnames';
import { find, isNil } from 'lodash';

/**
Expand Down Expand Up @@ -139,8 +138,6 @@ function RichText(
children,
allowedFormats,
withoutInteractiveFormatting,
style,
className,
placeholder,
disabled,
preserveWhiteSpace,
Expand Down Expand Up @@ -168,7 +165,6 @@ function RichText(
__unstableOnExitFormattedText: onExitFormattedText,
__unstableOnCreateUndoLevel: onCreateUndoLevel,
__unstableIsSelected: isSelected,
...remainingProps
},
ref
) {
Expand Down Expand Up @@ -1103,10 +1099,9 @@ function RichText(
role: 'textbox',
'aria-multiline': true,
'aria-label': placeholder,
...remainingProps,
ref,
style: style ? { ...style, whiteSpace } : defaultStyle,
className: classnames( 'rich-text', className ),
style: defaultStyle,
className: 'rich-text',
onPaste: handlePaste,
onInput: handleInput,
onCompositionStart: handleCompositionStart,
Expand Down

0 comments on commit 363df9f

Please sign in to comment.