Skip to content

Commit

Permalink
RNMobile: Fix autoscroll on ListBlock (#15048)
Browse files Browse the repository at this point in the history
* RNMobile: Add ability to send extra props (i.e. props needed just for mobile) to the list block.

* Adding onCaretVerticalPositionChange to RichText via context

* Passing onCaretVerticalPositionChange via context to RichText for all RichText based blocks

This makes it not necessary to pass onCaretVerticalPositionChange as a prop directly to RichText from the block component.

* Update jest snapshot for block-edit
  • Loading branch information
etoledom authored Apr 30, 2019
1 parent 447dd27 commit 297c2f4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`BlockControls should render a dynamic toolbar of controls 1`] = `
"clientId": undefined,
"isSelected": true,
"name": undefined,
"onCaretVerticalPositionChange": undefined,
"onFocus": undefined,
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/block-editor/src/components/block-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class BlockEdit extends Component {
);
}

propsToContext( name, isSelected, clientId, onFocus ) {
return { name, isSelected, clientId, onFocus };
propsToContext( name, isSelected, clientId, onFocus, onCaretVerticalPositionChange ) {
return { name, isSelected, clientId, onFocus, onCaretVerticalPositionChange };
}

render() {
const { name, isSelected, clientId, onFocus } = this.props;
const value = this.propsToContext( name, isSelected, clientId, onFocus );
const { name, isSelected, clientId, onFocus, onCaretVerticalPositionChange } = this.props;
const value = this.propsToContext( name, isSelected, clientId, onFocus, onCaretVerticalPositionChange );

return (
<BlockEditContextProvider value={ value }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ const RichTextContainer = compose( [
return {
isSelected: context.isSelected,
clientId: context.clientId,
onCaretVerticalPositionChange: context.onCaretVerticalPositionChange,
};
}

Expand All @@ -774,6 +775,7 @@ const RichTextContainer = compose( [
clientId: context.clientId,
isSelected: context.isSelected,
onFocus: context.onFocus || ownProps.onFocus,
onCaretVerticalPositionChange: context.onCaretVerticalPositionChange,
};
} ),
] )( RichText );
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/heading/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class HeadingEdit extends Component {
} }
onFocus={ this.props.onFocus } // always assign onFocus as a props
onBlur={ this.props.onBlur } // always assign onBlur as a props
onCaretVerticalPositionChange={ this.props.onCaretVerticalPositionChange }
onChange={ ( value ) => setAttributes( { content: value } ) }
onMerge={ mergeBlocks }
onSplit={ this.splitBlock }
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/paragraph/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class ParagraphEdit extends Component {
isSelected={ this.props.isSelected }
onFocus={ this.props.onFocus } // always assign onFocus as a props
onBlur={ this.props.onBlur } // always assign onBlur as a props
onCaretVerticalPositionChange={ this.props.onCaretVerticalPositionChange }
style={ style }
onChange={ ( nextContent ) => {
setAttributes( {
Expand Down

0 comments on commit 297c2f4

Please sign in to comment.