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

[RMmobile] Add Enter.key detection to the Title block #13500

merged 3 commits into from Jan 26, 2019


None yet
2 participants
Copy link

daniloercoli commented Jan 25, 2019

This PR adds Enter.key handling to Title block, and gives the ability to add a new block after it.

This PR set multiline=false, and detect the Enter.key with the default onSubmitEditing prop given by the underlying RN component. It adds a new default empty block after the current. (Default logic on the web).

onSubmitEditing is a very reliable way of detecting Enter.key on TextInput with multiline = false, and works on both HW and SW keyboard without the necessity of implementing hacks with TextWatchers and keyListeners -

Note: onSubmitEditing does hide the keyboard at the moment, it's a default behavior (at least) on Android. We may need to migrate the Title to RichText if there is no way to circumnavigate this problem.

Note 2: At the moment there is not split in place for the title filed. If you tap enter on the middle of the field there is no split yet.

Previous PR here: #13480

Copy link

diegoreymendez left a comment

This is working fine, but I believe it would be to our advantage to try and use more of the web code where possible.

As mentioned in the comment I tested copying some of the web code, and it works great.

@@ -42,6 +48,14 @@ class PostTitle extends Component {
this.props.onUpdate( title );

onEnter( ) {

This comment has been minimized.


diegoreymendez Jan 25, 2019


We could remove this method entirely and instead copy (and call) this method from the web .js sources.

I've tried it locally and it works and it works.

The advantage of using the same code as the web .js file is that it should make it easier for us to maintain this sourcefile if there are changes, or eventually unify it completely.

numberOfLines={ 0 }
multiline={ false }
onSubmitEditing={ this.onEnter }

This comment has been minimized.


diegoreymendez Jan 25, 2019


For the comment above to work, this would become onSubmitEditing={ this.props.onEnterPress }

This comment has been minimized.


daniloercoli Jan 25, 2019

Author Contributor

Nice find @diegoreymendez!

Tested here as well, and worked without problems 👍 I've updated this PR and main PR gb-mobile side.


This comment has been minimized.

Copy link

diegoreymendez commented Jan 25, 2019

Nice work @daniloercoli !

Merge branch 'master' of into …

* 'master' of (29 commits)
  Update for RangeControl documentation (#12564)
  Plugin: Deprecate gutenberg_load_list_reusable_blocks (#13456)
  Update the columns attribute in onSelectImages so that if images are removed via the media modal, the columns can't be higher than the new number of images (#13488)
  Replace the fullscreen "exit" icon with a back arrow (#13403)
  Include :visited links in button color (#12183)
  Amazon Kindle block (#13510)
  Plugin: Deprecate gutenberg_prepare_blocks_for_js (#13457)
  Add watcher on Linux: change fs to node-watch (#13448)
  Plugin: Deprecate `gutenberg` theme support (#13458)
  Datepicker: Add inValidDay support (#12962)
  Block Switcher: Render disabled button even if multi-selection (#13431)
  Plugin: Deprecate gutenberg_register_post_types (#13468)
  Plugin: Deprecate register_tinymce_scripts (#13466)
  Set minimum of words for RSS excerpt (#13502)
  Plugin: Deprecate gutenberg_get_block_categories (#13454)
  Plugin: Deprecate gutenberg_content_block_version (#13469)
  API Fetch: Expose nonce on created middleware function (#13451)
  Plugin: Remove list screens integrations (#13459)
  Plugin: Remove core-defined block detection functions (#13467)
  Spec Parser: Move generated spec parser to package (#13493)

@daniloercoli daniloercoli merged commit acb42fa into master Jan 26, 2019

1 check passed

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

@daniloercoli daniloercoli deleted the rnmobile/372-enter-key-detection-to-title branch Jan 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment