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

Revert the removal of isNative #1205

Closed
wants to merge 1 commit into from

Conversation

rgrove
Copy link
Contributor

@rgrove rgrove commented Oct 4, 2017

Preventing native text input events completely breaks autocorrect, autocomplete, auto-capitalization, predictive text, and double-space period insertion on iOS. In order to allow iOS to perform these kinds of operations, we have to avoid preventing the default event behavior and allow native input handling whenever possible.

This is mostly a reversion of the changes introduced in #1088, but I've tried to maintain the cleanup that was done in packages/slate-react/src/plugins/core.js's onBeforeInput method since then.

That method also includes one additional difference, which is the use of change.deleteCharBackward() to avoid double input when isNative is true. Restoring the previously removed isNative code throughout the codebase no longer seems to be enough to prevent rendering double input since focus-related state changes cause the isNative state to get reset to false before rendering happens. Deleting the inserted char seems like a bit of a hacky workaround to me, but it does work, and I wasn't able to come up with a better solution with my limited knowledge of the codebase. I'm open to suggestions.

Fixes #1176
Fixes #1177

Preventing native text input events completely breaks autocorrect,
autocomplete, auto-capitalization, predictive text, and double-space
period insertion on iOS. In order to allow iOS to perform these kinds of
operations, we have to avoid preventing the default event behavior
and allow native input handling whenever possible.

Fixes ianstormtaylor#1176
Fixes ianstormtaylor#1177

See also: ianstormtaylor#1088

// If the state has been changed natively, never re-render, or else we'll
// end up duplicating content.
if (props.state.isNative) return false
Copy link
Collaborator

Choose a reason for hiding this comment

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

This never appears to be true. From what I can tell the change.state.isNative gets set to true, but this doesn't get updated in the props before it checks here.

@@ -21,6 +21,7 @@ const DEFAULTS = {
selection: Selection.create(),
history: History.create(),
data: new Map(),
isNative: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious if this should go as a flag on the change object instead along with merge and save

@rgrove
Copy link
Contributor Author

rgrove commented Oct 13, 2017

Thanks for the feedback, @YurkaninRyan!

I'm going to close this PR in favor of an alternative approach (discussed in #1177). I'll keep your suggestions in mind as I work on that.

@rgrove rgrove closed this Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants