Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[RMmobile] Add Enter.key detection to the Title block #13500
Conversation
daniloercoli
added
the
Mobile App Compatibility
label
Jan 25, 2019
daniloercoli
requested a review
from
diegoreymendez
Jan 25, 2019
Jan 25, 2019
This was referenced
diegoreymendez
reviewed
Jan 25, 2019
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.
This comment has been minimized.
diegoreymendez
Jan 25, 2019
Contributor
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.
multiline | ||
numberOfLines={ 0 } | ||
multiline={ false } | ||
onSubmitEditing={ this.onEnter } |
This comment has been minimized.
This comment has been minimized.
diegoreymendez
Jan 25, 2019
Contributor
For the comment above to work, this would become onSubmitEditing={ this.props.onEnterPress }
This comment has been minimized.
This comment has been minimized.
daniloercoli
Jan 25, 2019
Author
Contributor
Nice find @diegoreymendez!
Tested here as well, and worked without problems
diegoreymendez
approved these changes
Jan 25, 2019
This comment has been minimized.
This comment has been minimized.
Nice work @daniloercoli ! |
daniloercoli commentedJan 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 - https://facebook.github.io/react-native/docs/textinput#onsubmitediting
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