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

fix(input): update $viewValue when cleared#14772

Open
wesleycho wants to merge 1 commit into
angular:masterfrom
wesleycho:fix/ie-input
Open

fix(input): update $viewValue when cleared#14772
wesleycho wants to merge 1 commit into
angular:masterfrom
wesleycho:fix/ie-input

Conversation

@wesleycho

Copy link
Copy Markdown
Contributor
  • Fix when user clicks clear button in an input element in IE, $viewValue not being correctly updated

This should fix #11193.

@Narretz

Narretz commented Jun 14, 2016

Copy link
Copy Markdown
Contributor

Cool! I believe writing a test is difficult because we can't click the clear button?

@wesleycho wesleycho force-pushed the fix/ie-input branch 2 times, most recently from 2445f95 to 1da5563 Compare June 14, 2016 15:51
@wesleycho

Copy link
Copy Markdown
Contributor Author

Yeah - fussing around with this a bit to get the right condition currently, but I think the right fix might be attainable here.

@wesleycho

Copy link
Copy Markdown
Contributor Author

This is a little tough - so falsy model changes will convert to the empty string, so this potentially breaks some behavior. Any ideas on good workarounds for that situation?

@wesleycho wesleycho force-pushed the fix/ie-input branch 10 times, most recently from 6273af0 to d997158 Compare June 14, 2016 17:14
Comment thread src/ng/directive/input.js Outdated
var timeout;
var timeout, oldVal;
var viewValueUpdated = true, msieInput = msie >= 10 && msie <= 11;
if (msieInput && inputType === 'text') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only text inputs? Won't types such as number have the same issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're correct - I assumed it would have the spinner, but apparently not.

Comment thread src/ng/directive/input.js

function ieListener(ev) {
var val = element.val();
if (val === oldVal && !viewValueUpdated) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that the validity changed but the value did not (similar to the value === '' && ctrl.$$hasNativeValidators check in listener)? Although I'm not seeing how that would have been handled previously either (in the !hasEvent('input') case)...

Comment thread src/ng/directive/input.js Outdated
var timeout;
var timeout, oldVal;
var viewValueUpdated = false, msieInput = msie >= 10 && msie <= 11;
if (msieInput && attr.type in IE_INPUTS_WITH_CLEARING) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we even care about the type for setting the initial oldVal though? I'd think we'd always want to setup the oldVal if msieInput is true...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that trigger a potentially unnecessary DOM access though? That is likely more expensive than this check I think. I originally had it just accessing the value, I'd be fine changing it back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep it I think it should be part of the msieInput condition, not this setup condition.

But I'd think element.val() is cheap enough it doesn't matter.

@wesleycho

Copy link
Copy Markdown
Contributor Author

There are some complicated scenarios I'm having trouble figuring out a good solution to.

Here is an incomplete table:

Initial view value Initial model value View value after view change Model value after model change Erroneous IE input events Run $parsers/$validators
'' undefined '' N/A false true
'' null '' N/A false true
'' null N/A '' false true
'' undefined N/A N/A true false

- Fix when user clicks clear button in an input element in IE, $viewValue not being correctly updated
@gkalpak

gkalpak commented Jun 15, 2016

Copy link
Copy Markdown
Member

Wouldn't it be easier to just add an extra listener on IEs:

element.on('??mousedown/mouseup/click??', function(event) {
  deferListener(event, this, this.value);
});

@Narretz

Narretz commented Oct 7, 2016

Copy link
Copy Markdown
Contributor

@wesleycho Do you still want to work on this?

@wesleycho

Copy link
Copy Markdown
Contributor Author

Don't have the bandwidth anymore :( .

@blemaire

blemaire commented Jun 8, 2018

Copy link
Copy Markdown

What's the status on this issue (not doubt i'm not the only one encountering this)
Thanks

@gkalpak

gkalpak commented Jun 8, 2018

Copy link
Copy Markdown
Member

It has been abandoned (afaict) 😁
If anyone wants to take it over, we will be more than happy to offer guidance and reviews, but I don't think we have the resources to take it over, given that we have less than a month of active feature development before entering LTS.

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.

AngularJS binding does not update when IE's clear button is clicked

6 participants