-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[TextField] Fix TextField with Chinese input method #6562
Conversation
Use compositionstart event to prevent not selected words trigger event.
case 'compositionend': this.setState({isTyping: false}); break; | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to pass the event though to the appropriate composition prop if set. There are a couple of patterns for that, in use, either test if the prop is defined or (my preference) give the props empty arrow function defaults: () = {}
.
@@ -191,6 +191,9 @@ class TextField extends Component { | |||
* @param {string} newValue The new value of the text field. | |||
*/ | |||
onChange: PropTypes.func, | |||
onCompositionEnd: PropTypes.func, | |||
onCompositionStart: PropTypes.func, | |||
onCompositionUpdate: PropTypes.func, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can @ignore
these.
facebook/react#3926 I found the same React issue before I realised you'd already linked to it! 😄 Reading that, we'll need to test carefully that this fixes the issue across browsers. It seems the event order is not consistent. |
@@ -356,6 +361,14 @@ class TextField extends Component { | |||
} | |||
}; | |||
|
|||
handleComposition = (event) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you add a TODO comment explaining why this is needed (reference the FB issue), so we can revisit and remove the workaround if / when Facebook finally fix it (there is a PR pending review since Dec 2016).
After upgrade to v0.17.2 found this issue resolved by #6456 |
Use compositionstart event to prevent not selected words trigger event.
Closes #6527.
ref facebook/react#3926