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

feat: Toggle mobile Quote block citation #59097

Merged
Merged
Show file tree
Hide file tree
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
Next Next commit
refactor: Align RichText refs with web implementation
Previously, the native `RichText` implementation relied upon a bespoke
`setRef` prop to forward refs to the native rich text editor instance
(i.e., Aztec). While this worked fine for contexts where `RichText` was
used for the native platform only, it diverged from the web `RichText`.
This divergence created incompatibility for the context of a component
running on both web and native which passed a ref to `RichText`.

This refactor aligns the native `RichText` with the web implementation
so that refs may be passed under a single, unified `ref` prop. The ref
is then forwarded onto the native rich text editor instance, as it was
before.
  • Loading branch information
dcalhoun committed Feb 15, 2024
commit 5da5d0356e9c4d5f668693088c287b31c9814c5d
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 @@ -74,7 +74,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 @@ -528,13 +527,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 @@ -585,7 +584,6 @@ export function RichTextWrapper(
minWidth={ minWidth }
maxWidth={ maxWidth }
onBlur={ onBlur }
setRef={ setRef }
disableSuggestions={ disableSuggestions }
disableAutocorrection={ disableAutocorrection }
containerWidth={ containerWidth }
Expand Down Expand Up @@ -671,7 +669,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/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