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

Fix/Set focus on title for new posts on Android #611

Merged
merged 3 commits into from
Feb 19, 2019

Conversation

daniloercoli
Copy link
Contributor

This PR fixes wordpress-mobile/WordPress-iOS#10594 for Android.

Initially we've made a fully JS version of it here, but does't seem to work fine on Android, due to probably the way Android handle the focus.
I've spent some hrs trying to fix the issue on the Android side (native) without much luck, then added to the bridge the ability to send an event focus on title and used it in the android app.

In this PR we wait until the editor is mounted, listen for editorDidMount, and emit an event to set the focus on title when both content and title are empty.

Test 1

  • Use wp-android
  • Check out this branch and build the app from code
  • Start the app
  • Tap on the New Post button in the home screen
  • When the editor is mounted the keyboard should appear and the focus should be on the title

Test 2

  • Go to posts list
  • Edit a post made in GB
  • The editor should start but no focus on the title

Not sure if something is required on the iOS side. Tests are passing.

Copy link
Contributor

@mzorz mzorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised!
it's hard to see that we need so much just to get the focus where we want, but looking into the code it makes sense to me and the mechanism works alright, so, giving it the 👍
LGTM :shipit:

@daniloercoli daniloercoli merged commit 47eb9b5 into develop Feb 19, 2019
@daniloercoli daniloercoli deleted the fix/set-focus-on-title-android branch February 19, 2019 09:03
@daniloercoli
Copy link
Contributor Author

daniloercoli commented Feb 19, 2019

Not sure if something is needed on the iOS side, jest tests didn't report anything wrong, although I can't test it locally since yarn ios is broken again (** BUILD FAILED **). cc @diegoreymendez

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

Successfully merging this pull request may close these issues.

Gutenberg: focus title on entering a post
2 participants