Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(input[text]): composing function dosen't works properly in IE #16273

Merged

Conversation

jileeon
Copy link
Contributor

@jileeon jileeon commented Oct 13, 2017

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.

  • Code changes to investigate this problem(just added console.log)
    2017-10-12 17_53_02-engineering-system - c__users_jileeon_documents_git_engineering-system - _p
  • Scenario
  1. Just type '이재익' and focusout.(in IE and Chrome)
  • Result(attached images show differences)
    console.log in Chrome
    2017-10-12 18_57_52-developer tools - http___127 0 0 1_8888_system_requests_2279
    console.log in IE
    2017-10-12 18_58_43-f12
    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.

@googlebot
Copy link

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!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

1 similar comment
@googlebot
Copy link

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!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@jileeon
Copy link
Contributor Author

jileeon commented Oct 13, 2017

I signed it!

@googlebot
Copy link

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.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

1 similar comment
@googlebot
Copy link

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.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@jileeon
Copy link
Contributor Author

jileeon commented Oct 13, 2017

I signed it!

@jileeon jileeon force-pushed the fix-composing-doesnt-work-properly-in-IE branch from 00f14a7 to 2db08fd Compare October 13, 2017 07:50
@googlebot
Copy link

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

@jileeon jileeon changed the title fix(input): Composing function dosen't works properly in IE fix(input): composing function dosen't works properly in IE Oct 13, 2017
@jileeon jileeon force-pushed the fix-composing-doesnt-work-properly-in-IE branch from 2db08fd to 4528eec Compare October 13, 2017 09:07
@@ -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;
Copy link
Member

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?

Copy link
Contributor Author

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.

@jileeon jileeon changed the title fix(input): composing function dosen't works properly in IE fix(input[text]): composing function dosen't works properly in IE Oct 13, 2017
@gkalpak gkalpak added this to the Backlog milestone Oct 13, 2017
@gkalpak
Copy link
Member

gkalpak commented Oct 13, 2017

I guess we are not testing composition events, are we?

@Narretz
Copy link
Contributor

Narretz commented Oct 13, 2017

We should be testing this. But I wonder if it's possible in a unit test.

@Narretz
Copy link
Contributor

Narretz commented Oct 13, 2017

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

@jileeon jileeon force-pushed the fix-composing-doesnt-work-properly-in-IE branch 2 times, most recently from 6d0b4f3 to 11b72b8 Compare October 13, 2017 15:30
@jileeon jileeon force-pushed the fix-composing-doesnt-work-properly-in-IE branch from c058994 to b59f62d Compare January 11, 2018 13:48
@jileeon
Copy link
Contributor Author

jileeon commented Jan 11, 2018

@Narretz, I've rebased it on master.

Thanks.

@googlebot
Copy link

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 cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

1 similar comment
@googlebot
Copy link

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 cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@Narretz
Copy link
Contributor

Narretz commented Jan 12, 2018

I've added a test for this behavior.
If @gkalpak can give review the PR again, we should be good to go :)

@jileeon
Copy link
Contributor Author

jileeon commented Jan 12, 2018

@Narretz, Thank you for improving my comment and your effort.

@Narretz Narretz force-pushed the fix-composing-doesnt-work-properly-in-IE branch from 0fba027 to 7cd75e9 Compare January 12, 2018 16:42
@gkalpak
Copy link
Member

gkalpak commented Jan 25, 2018

LGTM except for the failing Travis tests 😥

@jileeon jileeon force-pushed the fix-composing-doesnt-work-properly-in-IE branch from 7cd75e9 to 4a5283b Compare January 25, 2018 12:58
@jileeon
Copy link
Contributor Author

jileeon commented Jan 25, 2018

@gkalpak FYI, I've rebased this on master.

@Narretz
Copy link
Contributor

Narretz commented Jan 25, 2018

The problem isn't solved by rebasing unfortunately. There's a problem with the composition events when jquery is active,

@jileeon
Copy link
Contributor Author

jileeon commented Jan 25, 2018

@Narretz, I ran 'should end composition on "compositionupdate" when event.data is ""' test. and I found compositionupdate event wasn't fired. So we have to change test code to trigger compositionupdate event. Unfortunately I don't know why.

@Narretz
Copy link
Contributor

Narretz commented Jan 25, 2018

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

@jileeon
Copy link
Contributor Author

jileeon commented Jan 25, 2018

@Narretz Sure I did(run with karma-jquery.conf.js). I hope we will find the root cause as soon as possible.

// 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;
Copy link
Member

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?)

Copy link
Contributor

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

Copy link
Member

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?

@Narretz
Copy link
Contributor

Narretz commented Jan 29, 2018

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?

@jileeon
Copy link
Contributor Author

jileeon commented Jan 30, 2018

@Narretz, You found the root cause. and Now I see this pull request is approved.

Thank You

@Narretz Narretz force-pushed the fix-composing-doesnt-work-properly-in-IE branch from 1f0688e to da79f73 Compare February 8, 2018 17:48
@Narretz Narretz merged commit c484213 into angular:master Feb 8, 2018
Narretz pushed a commit that referenced this pull request Feb 8, 2018
Narretz pushed a commit that referenced this pull request Feb 8, 2018
@jileeon jileeon deleted the fix-composing-doesnt-work-properly-in-IE branch February 9, 2018 01:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants