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

[RNMobile] add isSelected prop to PlainText-backed blocks #11989

Merged
merged 6 commits into from Nov 16, 2018

Conversation

Projects
None yet
3 participants
@mzorz
Contributor

mzorz commented Nov 16, 2018

Description

This is a follow up PR to #11857, bringing the same functionality to PlainText-backed blocks:

  • Promotes PlainText implementation to be a React Native component (so we can make use of the lifecycle events more clearly)
  • adds isSelected prop to Code and More blocks

By doing this, we can make it easier to handle the focus at the low level when isSelected is true.

How has this been tested?

To be tested as per indicated in wordpress-mobile/gutenberg-mobile#250

  1. make sure to select a block (tap on a block and see the up/down arrows appear, etc)
  2. now tap on the + inserter icon
  3. choose one of Code or More blocks (the only ones that currently are backed by PlainText implementation)
  4. observe the new block is inserted, the block is shown as selected (it has the up/down arrows and such) and the cursor starts blinking there (that is, it got the focus).

Screenshots

Before, the focus would not be gotten when a new "PlainText"-backed block was inserted:
cursor_after_insert_okno

Now, the cursor appears blinking after insertion:
cursor_after_insert_ok

Types of changes

Bug fix (non-breaking change which fixes an issue)

@mzorz mzorz requested a review from etoledom Nov 16, 2018

export default function CodeEdit( { attributes, setAttributes, style } ) {
export default function CodeEdit( props ) {
const { attributes, setAttributes } = props;
const { style } = attributes;

This comment has been minimized.

@daniloercoli

daniloercoli Nov 16, 2018

Contributor

It seems that style should be retrieved from props.

This comment has been minimized.

@mzorz

mzorz Nov 16, 2018

Contributor

my bad, addressed in 5f03b77

@daniloercoli

This comment has been minimized.

Contributor

daniloercoli commented Nov 16, 2018

LGTM once Travis is happy.

@daniloercoli daniloercoli self-requested a review Nov 16, 2018

@mzorz mzorz merged commit f9ddd68 into master Nov 16, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@mzorz mzorz deleted the rnmobile/is-selected-plain-text branch Nov 16, 2018

@mzorz mzorz restored the rnmobile/is-selected-plain-text branch Nov 17, 2018

@catehstn catehstn added this to the 4.5 milestone Nov 19, 2018

grey-rsi pushed a commit to OnTheGoSystems/gutenberg that referenced this pull request Nov 22, 2018

[RNMobile] add isSelected prop to PlainText-backed blocks (WordPress#…
…11989)

* handling isSelected in PlainText primitive through a deferred call to focus() on React Native TextInput

* adds isSelected prop support for Code block

* added isSelected prop to More block

* promoted PlainText native implentation to extend Component and reuse ReactNative lifecycle

* fixed lint warnings

* get style from props
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment