-
-
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] Breaks character composition #3394
Comments
This is not good. We'll try to look into this. You're welcome to send a PR if you get to the bottom of it 😁 or if you find what part of the code is responsible. Since we don't have Korean keyboard it might not be so easy for us to reproduce. your help is appreciated 😅 |
Geeze this is bad! I used to study Mandarin in college and I just changed my keyboard layout to a Chinese one and reproduced this...don't have a clue how to fix it though. Edit: Nope, nevermind. I couldn't reproduce it. Turns out I just configured the Chinese keyboard wrong on my mac. Looks like it's entering characters fine. I guess we'll have to rely on @TheRealK2 to help reproduce steps. |
I had some test and I found out this problem only appears when I have class Help extends React.Component {
constructor() {
super();
this.state = {
value1: '',
value2: ''
}
}
onChange({target: {value}}, name) {
this.setState(_.assign({}, this.state, {
[name]: value
}));
}
render() {
return (
<div>
<Dialog open={true}>
<TextField value={this.state.value1}
onChange={(e) => this.onChange(e, 'value1')} />
<br/>
<TextField value={this.state.value2}
onChange={(e) => this.onChange(e, 'value2')} />
</Dialog>
</div>
);
}
} |
@imtherealk is there a way I can easily type korean on my computer? 😄 |
@nathanmarks I hope this post will be helpful. You can enable 2-Set Korean input method on your Mac. http://www.macinfo.us/how-to-type-korean-characters-on-your-mac.php |
@imtherealk thanks! I'm looking forwards to trying this 😄 |
@imtherealk 가 think I got the korean keyboard working, time to try this out 👍 |
I've found what is causing the issue... eh, sort of. Basically, the I found if I typed quickly enough but also on some randomish timing pattern, I could actually trigger a 가 composition. Looking at your code above @imtherealk , you'll see that the component rendering the I tested this by wrapping the Here's the wrapper I used to test: class WrappedTextField extends React.Component {
state = {
value1: '',
};
shouldComponentUpdate(nextProps) {
return nextProps.value !== this.props.value;
}
onChange({target: {value}}, name) {
this.setState(Object.assign({}, this.state, {
[name]: value,
}));
}
render() {
return (
<TextField
name="woof"
value={this.props.value}
onChange={(event) => this.onChange(event, 'value1')}
/>
);
}
}
WrappedTextField.propTypes = {
value: React.PropTypes.string,
}; @newoga any idea why this would happen specifically with the dialog? |
@newoga It is specifically a combination between our Here is a demo just using <div>
<TextField value={this.state.value1} onChange={(event) => this.onChange(event, 'value1')} />
<input value={this.state.value2} onChange={(event) => this.onChange(event, 'value2')} />
</div> @callemall/material-ui Do you have any idea why this might be happening (off the top of your head)? I'm going to continue debugging it after I get home etc tonight. |
That was the first thought I had when you mentioned it had to do with Dialog, but haven't had a chance to investigate it yet (just got to hotel |
@newoga no worries! Was just checking if anyone knew, I plan on investigating tonight |
Found the problem. Writing a failing test. removed my last reply... still verifying via the test |
I can't seem to get the phantomjs test to fail, sigh. I'll have to fix this without a test for now. Here's the main symptom of the issue though: The double render is due to some issues with portal pattern ( |
I did some investigation last night and figured out that the Here's where the composition event appeared to break: I wondered why that was happening during the composition step, so I took a closer look at This was only happening by controlling the There are several options here (not mutually exclusive):
shouldComponentUpdate(nextProps, nextState, nextContext) {
return (
!shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState) ||
!shallowEqual(this.context, nextContext)
);
} |
@nathanmarks Wow great job 👍 👍 This wasn't an easy task! I think it's best if we remove the setState(). will that be a breaking change? |
@alitaheri Thanks! It will break some behaviour for using it uncontrolled 😠 lol 😄 |
Oops 😅 Well @imtherealk How urgent is this? If it's not so urgent we plan on removing state from our components so it will be automatically fixed. otherwise, follow 2. @nathanmarks 3 will not be possible, with our inline styles that function will always return true |
@alitaheri It works fine unless the user is passing their own inline styles, that's only the case with the leaf nodes that |
Oh right. it's a good fix for now 👍 atleast it will give @imtherealk a good work around for now. But it's not concrete. We have to fix it at the core 😁 |
@alitaheri RIP IT ALL OUT! 😄 |
YEAH |
Ok, so you think we should implement the |
yeah, that should give our Korean users a temporary work around so they can go on with their work. After we do the migration this will automatically be fixed by design 👍 |
will do 👍 |
Thanks a lot 👍 👍 😁 |
@nathanmarks @alitaheri not in a hurry, actually. I just found a bug and wanted u know it. thanks a lot for the fix :) |
Great stuff @nathanmarks, sorry, I've been limited on my travels (my Internet isn't so great as well at the hotel). Thanks for taking this on! Also yay for no state! 😄 |
@imtherealk It's a pretty annoying bug! |
@nathanmarks @alitaheri |
This bug still happens when I write first-letter. Compositing Korean is disable for first-letter. (`ㄱㅏ나안` should be `가나안`) Anyone have this experience...? It looks `TextField` has a bug because normal `input` element or `draftJS` works well.I see this bug on Chrome for OSX El Cap and Windows 10. Safari doesn't make this bug. |
(sorry for my english 😢 ) @beingbook is right. This bug still happen. When i typed first letter to Because typing first letter cause changing of And then So, |
@pgonee I will make sure this doesn't on the |
Is there any updates on this issue? seems it still happened in version v0.16.1, thanks. |
happened again,may it resovled |
[TextField] Breaks character composition mui#3394 Bug Fixed
@nathanmarks That issue seems highly correlated to #4430.
I agree, that would be the best fix IMHO. |
My temporary workaround for the 'first letter' issue is
|
Tiny change. It seems to me that, when the component is conrolled, 'value' needs to be checked only in componentWillReceiveProps, and event.target.value in handleInputChange has nothing to do with hasValue state. At least, this PR can fix mui#3394 issue which, still remaining despite mui#5540, breaks 'first' character composition of CJK or other input methods when used with, for example, redux-form.
Tiny change. It seems to me that, when the component is conrolled, 'value' needs to be checked only in componentWillReceiveProps, and event.target.value in handleInputChange has nothing to do with hasValue state. At least, this PR can fix mui#3394 issue which, still remaining despite mui#5540, breaks 'first' character composition of CJK or other input methods when used with, for example, redux-form.
Any progress on this bug? Still got Chinese IME trouble on version 0.17.1 |
* [TextField]Fix first character composition issue #3394 Tiny change. It seems to me that, when the component is conrolled, 'value' needs to be checked only in componentWillReceiveProps, and event.target.value in handleInputChange has nothing to do with hasValue state. At least, this PR can fix #3394 issue which, still remaining despite #5540, breaks 'first' character composition of CJK or other input methods when used with, for example, redux-form. * Add tests of hasValue Tests for uncontrolled component's hasValue state regarding event.target.value. Tests for controlled component's hasValue state reagarding value prop.
* [TextField]Fix first character composition issue mui#3394 Tiny change. It seems to me that, when the component is conrolled, 'value' needs to be checked only in componentWillReceiveProps, and event.target.value in handleInputChange has nothing to do with hasValue state. At least, this PR can fix mui#3394 issue which, still remaining despite mui#5540, breaks 'first' character composition of CJK or other input methods when used with, for example, redux-form. * Add tests of hasValue Tests for uncontrolled component's hasValue state regarding event.target.value. Tests for controlled component's hasValue state reagarding value prop.
TextField
component breaks composite chracters.When I set
value
property from the container's state it breaks character composition.For example, I have a react component like this
In korean, to input charater '가', I have to enter 'ㄱ' and then 'ㅏ', and they are composed into '가'
But, when value changed to non-empty value from empty value, it breaks a composition. So I can't enter '가' to the
TextField
The text was updated successfully, but these errors were encountered: