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 dictation issue on iOS #610

Merged
merged 3 commits into from
Feb 21, 2019
Merged

Fix dictation issue on iOS #610

merged 3 commits into from
Feb 21, 2019

Conversation

etoledom
Copy link
Contributor

fixes #606

This PR fixes the dictation content disappearing from Paragraph blocks on iOS.

This is why the issue happens:

  1. This happened just on empty TextViews (then explanation will assume that).
  2. When the person is dictating, just textViewDidChange is called with the new text. (No insertText) is called.
  3. When dictation finishes, textViewDidChange is called first with the text existing previous the dictation (an empty string in this case).
  4. RNAztec propagates to the JS side the new content with that empty string.
  5. The new text from dictation is inserted and textViewDidChange is called again with the full new text. (and RNAztec informs again the JS side)
  6. RNAztec receives a setContents message from JS from the previous propagation of the empty string. Since JS resets eventCount to zero (undefined) when the string is empty, RNAztec refresh its state to an empty string, and the dictation string is lost.
  7. RNAztec receives a setContents message from JS with the dictation string, but it's ignored since it has eventCount == 1

To fix the issue, I noticed that the step 3 is always called between dictationRecordingDidEnd and insertDictationResult.
Activating a flag in between those method calls to avoid propagating the empty string fixed the issue.

dictation

To test:

  • Build and run the project.
  • Create an empty paragraph block.
  • Test the iOS dictation feature.
  • Check that it behaves properly.

@etoledom etoledom self-assigned this Feb 18, 2019
@etoledom etoledom added this to the Beta milestone Feb 18, 2019
Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

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

I'm not sure the changes in this PR are the best way to resolve this issue as it feels a bit hackish.

That said, through testing I wasn't able to see any issues, so I'm approving it.

@etoledom
Copy link
Contributor Author

Thank you for the review!

I'm not sure the changes in this PR are the best way to resolve this issue as it feels a bit hackish.

I agree it's not an elegant solution. I tested other possibility and it seems to be the only way to fix it that doesn't involve touching JS and (probably) Android too. While not the best, it's probably is the simplest.

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

Successfully merging this pull request may close these issues.

[iOS] Voice-to-text: after input, content is removed
2 participants