Skip to content

Commit

Permalink
Re-merged change by @dcalhoun from #59097
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 28, 2024
1 parent d2433cf commit 2bf1dbd
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function removeNativeProps( props ) {
fontStyle,
minWidth,
maxWidth,
setRef,
disableSuggestions,
disableAutocorrection,
...restProps
Expand Down
12 changes: 6 additions & 6 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ export function RichTextWrapper(
minWidth,
maxWidth,
onBlur,
setRef,
disableSuggestions,
disableAutocorrection,
containerWidth,
onEnter: onCustomEnter,
...props
},
forwardedRef
providedRef
) {
const instanceId = useInstanceId( RichTextWrapper );

Expand Down Expand Up @@ -529,13 +528,13 @@ export function RichTextWrapper(
[ onReplace, __unstableMarkAutomaticChange ]
);

const mergedRef = useMergeRefs( [ forwardedRef, fallbackRef ] );
const mergedRef = useMergeRefs( [ providedRef, fallbackRef ] );

return (
<RichText
clientId={ clientId }
identifier={ identifier }
ref={ mergedRef }
nativeEditorRef={ mergedRef }
value={ adjustedValue }
onChange={ adjustedOnChange }
selectionStart={ selectionStart }
Expand Down Expand Up @@ -586,7 +585,6 @@ export function RichTextWrapper(
minWidth={ minWidth }
maxWidth={ maxWidth }
onBlur={ onBlur }
setRef={ setRef }
disableSuggestions={ disableSuggestions }
disableAutocorrection={ disableAutocorrection }
containerWidth={ containerWidth }
Expand Down Expand Up @@ -672,7 +670,9 @@ ForwardedRichTextContainer.Content.defaultProps = {
value: '',
};

ForwardedRichTextContainer.Raw = RichText;
ForwardedRichTextContainer.Raw = forwardRef( ( props, ref ) => (
<RichText { ...props } nativeEditorRef={ ref } />
) );

/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,8 @@ export class RichText extends Component {
ref={ ( ref ) => {
this._editor = ref;

if ( this.props.setRef ) {
this.props.setRef( ref );
if ( this.props.nativeEditorRef ) {
this.props.nativeEditorRef( ref );
}
} }
style={ {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ function ButtonEdit( props ) {
<View pointerEvents="none" style={ outLineStyles } />
) }
<RichText
setRef={ onSetRef }
ref={ onSetRef }
placeholder={ placeholderText }
value={ text }
onChange={ onChangeText }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/quote/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function QuoteEdit( {
<Caption
attributeKey="citation"
tagName={ isWebPlatform ? 'cite' : undefined }
style={ { display: 'block' } }
style={ isWebPlatform && { display: 'block' } }
isSelected={ isSelected }
attributes={ attributes }
setAttributes={ setAttributes }
Expand Down
10 changes: 4 additions & 6 deletions packages/block-library/src/quote/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
getEditorHtml,
fireEvent,
within,
waitFor,
typeInRichText,
} from 'test/helpers';

Expand Down Expand Up @@ -40,14 +39,9 @@ describe( 'Quote', () => {
},
}
);
// Await inner blocks to be rendered
const citationBlock = await waitFor( () =>
screen.getByPlaceholderText( 'Add citation' )
);

// Act
fireEvent.press( quoteBlock );
// screen.debug();
let quoteTextInput =
within( quoteBlock ).getByPlaceholderText( 'Start writing…' );
typeInRichText( quoteTextInput, 'A great statement.' );
Expand All @@ -61,6 +55,10 @@ describe( 'Quote', () => {
'Start writing…'
)[ 1 ];
typeInRichText( quoteTextInput, 'Again.' );
fireEvent.press( screen.getByLabelText( 'Navigate Up' ) );
fireEvent.press( screen.getByLabelText( 'Add citation' ) );
const citationBlock =
await screen.findByPlaceholderText( 'Add citation' );
const citationTextInput =
within( citationBlock ).getByPlaceholderText( 'Add citation' );
typeInRichText( citationTextInput, 'A person' );
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class PostTitle extends Component {
accessibilityHint={ __( 'Updates the title.' ) }
>
<RichText.Raw
setRef={ this.setRef }
ref={ this.setRef }
accessibilityLabel={ this.getTitle( title, postType ) }
tagName={ 'p' }
tagsToEliminate={ [ 'strong' ] }
Expand Down

0 comments on commit 2bf1dbd

Please sign in to comment.