-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(input[text]): composing function dosen't works properly in IE #16273
fix(input[text]): composing function dosen't works properly in IE #16273
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
I signed it! |
00f14a7
to
2db08fd
Compare
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
2db08fd
to
4528eec
Compare
src/ng/directive/input.js
Outdated
@@ -1261,7 +1261,7 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) { | |||
$browser.defer.cancel(timeout); | |||
timeout = null; | |||
} | |||
if (composing) return; | |||
if (composing && ev.originalEvent.data !== undefined) return; |
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.
So, should composing
be set to false
if composing $$ ev.originalEvent.data === undefined
?
Also, where does originalEvent
come from?
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.
That's right. Because, In IE, 'compositionupdate' event still occurred although an user focused out of text input. and originalEvent comes from this text input.
I guess we are not testing |
We should be testing this. But I wonder if it's possible in a unit test. |
A few of the input tests fail with this change - related to the use of originalEvent: https://travis-ci.org/angular/angular.js/jobs/287472115 |
6d0b4f3
to
11b72b8
Compare
c058994
to
b59f62d
Compare
@Narretz, I've rebased it on master. Thanks. |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
1 similar comment
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
I've added a test for this behavior. |
@Narretz, Thank you for improving my comment and your effort. |
0fba027
to
7cd75e9
Compare
LGTM except for the failing Travis tests 😥 |
7cd75e9
to
4a5283b
Compare
@gkalpak FYI, I've rebased this on master. |
The problem isn't solved by rebasing unfortunately. There's a problem with the composition events when jquery is active, |
@Narretz, I ran |
Did you run the tests with jquery? As you can see the tests work with jqlite. I suspect that browserTrigger works differently when jquery is included. We cannot simply change the tests so they pass, we must find the root cause |
@Narretz Sure I did(run with |
src/ng/directive/input.js
Outdated
// End composition when ev.data is empty string on 'compositionupdate' event. | ||
// When the input de-focusses (e.g. by clicking away), IE triggers 'compositionupdate' | ||
// instead of 'compositionend'. | ||
if (ev.data === '') composing = false; |
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.
Setting composing
to false
isn't enough. You also need to call the listener
.
Maybe add a check here and in compositionend
listener below, to only call listener()
if composing
was true
before (to avoid calling it twice on browsers that may trigger both events - or is that impossible?)
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.
Well, I've tested it in a real world scenario and it is enough, because IE also fires the change event afterwards.
We could still implement your suggestion. It might help with another IE issue: #13617
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.
I see. Makes sense. Any idea why tests fail on Travis then?
It appears that jquery sets the event.data property to undefined when it is explicitly set to empty string, at least for compositionupdate with dispatchEvent. @mgol do you know if this is expected behavior? |
@Narretz, You found the root cause. and Now I see this pull request is approved. Thank You |
1f0688e
to
da79f73
Compare
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix
What is the current behavior? (You can also link to an open issue here)
Composing function dosen't works properly in IE. Please refer to #6656 and "Other information" below.
What is the new behavior (if this is a feature change)?
It works properly in IE.
Does this PR introduce a breaking change?
No.
Please check if the PR fulfills these requirements
Other information:
I have investigated on #6656 issue and I found composing function works differently in only IE.
I confirmed this by the scenario below.
console.log in Chrome
console.log in IE
It shows that last values of $viewValue are different. '이재이'(IE) != '이재익'(Chrome)
Because 'compositionend' event is not occurred in IE. So $viewValue is not updated with last value in the textbox. It means that IE triggers composition events('compositionstart', 'compositionupdate', 'compositionend') wrong.
So I added additional condition(ev.originalEvent.data !== undefined) on 'if (composing) return;' statement.
As you saw these console logs(IE and Chrome) above, this additional condition makes composing function works properly in IE.(by checking ev.originalEvent.data value. if its value is undefined, $viewValue going to be updated with last value in the textbox in IE. So it works like 'compositionend').
In addition, When IE fixes this wrong event triggering, It works fine without any problems.