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

Input directive model sometimes isn't updated in IE when typing fast #16519

Open
1 of 3 tasks
jkopponen opened this issue Apr 4, 2018 · 10 comments
Open
1 of 3 tasks

Input directive model sometimes isn't updated in IE when typing fast #16519

jkopponen opened this issue Apr 4, 2018 · 10 comments

Comments

@jkopponen
Copy link

I'm submitting a ...

  • bug report
  • feature request
  • other

Current behavior:
Sometimes input directives model (viewValue) is not updated when typing to input field.
Expected / new behavior:
viewValue and input value are same after typing.

Minimal reproduction of the problem with instructions:
Sometimes input directives model (viewValue) is not updated when typing to input field.
This occurs with fast typing and slow computer.

This happens because in IE, angular listens keydown -event and has timeout handling that skips new keystrokes if handling of previous keydown is ongoing.
And previous ongoing keydown handling reads old value of input because the value is not updated immediately when key is pressed down.

AngularJS version: 1.6.6

Browser: IE 11

Anything else:

@gkalpak
Copy link
Member

gkalpak commented Apr 4, 2018

A solution would be to actually defer the listener (right now it seems that we use a mix of throttling/deferring):

var deferListener = function(ev, input, origValue) {
if (!timeout) {
timeout = $browser.defer(function() {
timeout = null;
if (!input || input.value !== origValue) {
listener(ev);
}
});
}
};

I.e. we would cancel the pending timeout and set a new one each time.

As a result the model would be updated later if the user types too fast. If we consider this a problem, we could use proper deferring in addition to the current implementation.

@gkalpak gkalpak added this to the Backlog milestone Apr 4, 2018
@Narretz Narretz changed the title Input directive model isn't randomly updated in IE. Input directive model sometimes isn't updated in IE when typing fast Apr 5, 2018
@jbedard jbedard self-assigned this May 3, 2018
@jkopponen
Copy link
Author

Hi,
I am just wondering is there any progress with this issue?
This has been assigned over 6 months.

@jbedard
Copy link
Contributor

jbedard commented Jan 13, 2019

This most likely won't be fixed as the project is now in LTS mode and only serious/security issues will be fixed.

@jbedard jbedard modified the milestones: Backlog, 1.7.x - won't fix Jan 13, 2019
@inad9300
Copy link

How is a bug in a core functionality of AngularJS not serious? 😅 If I understand correctly, when this happens, users will see something on the screen different than the underlying value kept in JavaScript. If this is truly the case, I sure hope no one is using AngularJS for anything... serious.

@petebacondarwin
Copy link
Member

AngularJS is a mature legacy project, which is no longer being actively developed. We instigated LTS mode last summer, to provide basic on-going support for 3 years. This includes fixing recent regressions (introduced by commits since 1.7.0), security concerns and catastrophic failures caused to by changes to things outside of our control (e.g. new releases of browsers or JQuery).

Although this is indeed a bug in the core, it is not a recent regression, and does not appear to affect a large number of projects. Moreover it only appears to impact apps running on a few legacy browsers.

Therefore it is not on our road map for fixing in a future release.

One of the benefits of AngularJS no longer receiving significant development, is that it is now much less risky to fork the project and fix bugs that are specific to your scenario. Previously this was not recommended as it would involve a significant effort to ensure that your fork was kept up to date with the main AngularJS project. Since LTS began there are very few changes to AngularJS and so forking the project is now a much more viable approach for bugs like this.

thejhh added a commit to norjs/angular.js that referenced this issue Apr 12, 2019
This fixes the IE issue reported to AngularJS at angular#16519

Instead of ignoring key events, we cancel the previous deferred timeout and declare a new one each time. 

This fixes the problem that references to `input` and `origValue` inside the deferred function do not point to the most recent key event occurrence.
@thejhh
Copy link

thejhh commented Apr 12, 2019

I made the fix in the above commit and also run tests with Travis-CI. However, I'm not sure how to make my own deployment package yet.

@gkalpak
Copy link
Member

gkalpak commented Apr 14, 2019

@jheusala, I am not sure what you mean by "make my own deployment package". If you are asking how to build AngularJS to generate production scripts (to include in your app) from your local copy of the repo, you find the commands here. (Hint: It's yarn grunt package 😉)

@thejhh
Copy link

thejhh commented Apr 15, 2019

I have tested this fix and it makes input on IE much more responsive. It's still too early to tell if the problem with last character missing is fixed, but I have not seen that happen anymore.

If I would do a merge request, is there any chance this fix could be accepted to LTS? Sure, it's an EOL browser, but some of us still need to support it, and this is clearly a bug in AngularJS.

PS: I saw there was other places in the code using the same paradigm of ignoring event if timeout was already in place. My fix is precisely to this input event problem; there may be other bugs affected by the same paradigm.

@thejhh
Copy link

thejhh commented Apr 15, 2019

AFAIK it also does not affect modern browsers, since this part of the code is in IE-only block. Unless there is other (legacy) browsers that use it; in that case, it would be a bug for them, too.

@gkalpak
Copy link
Member

gkalpak commented Apr 16, 2019

I'm afraid this won't happen, @jheusala. We are ourselves tempted to keep fixing stuff like this, but such bugs will always be around and we should stick to our LTS policy 🕴

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants