Skip to content
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

Input event triggered on Internet Explorer when placeholder changed #9070

Closed
schnepe2 opened this issue Jun 27, 2016 · 11 comments
Closed

Input event triggered on Internet Explorer when placeholder changed #9070

schnepe2 opened this issue Jun 27, 2016 · 11 comments
Assignees
Labels
bug Errors

Comments

@schnepe2
Copy link
Contributor

In IE 11 (and others I think) the input event is fired when the placeholder is used and the displayed data changes. This causes change detection code like

input.addListener("valueChanged", function (e) {
  ...
}, this});

to not work as expected anymore. The issue seems to be at Browser level:
https://connect.microsoft.com/IE/feedback/details/885747/ie-11-fires-the-input-event-when-a-input-field-with-placeholder-is-focused
https://connect.microsoft.com/IE/feedback/details/856700/ie11-ie10-send-input-events-at-times-when-it-is-not-appropriate

Is there a way to work around this issue unit it might be fixed by MS?

@level420
Copy link
Member

@schnepe2 could you please create a simple playground example which shows the bug?
Please use the current master playground available at http://qooxdoo.github.io/devel/playground/ for this. Thank you.

@schnepe2
Copy link
Contributor Author

Try it in IE and a "changeEvent" will immediately occur when you click into the input field (as soon as the placeholder text disappears).
Run it in e.g. Firefox / Chrome / PaleMoon / ... and the event first fires when you really changed something:
http://tinyurl.com/gtvulqq

@schnepe2
Copy link
Contributor Author

schnepe2 commented Jun 27, 2016

My current (ugly, 'cause it uses the 'internal' method getChecks to get access to protected member) work-around is:

// Prevent IE to use its native CSS placeholder attribute
// (IE placeholder event issue workaround)
if ( qx.core.Environment.get("engine.name") == "mshtml" || qx.core.Environment.get("browser.name") == "edge" )
{
  qx.core.Environment.getChecks()["css.placeholder"] = function () {
    return false;
  };
  qx.core.Environment.invalidateCacheKey("css.placeholder")
}

...placed somewhere at my Application.js.

@johnspackman
Copy link
Member

a better way of handling this would be to change the detection code for css.placeholder. The method that would need changing is qx.bom.client.Css.getPlaceholder.

If you can make the fix and submit a PR, we can get it included in the next release?

@johnspackman johnspackman added the bug Errors label Jun 28, 2016
@schnepe2
Copy link
Contributor Author

...no I can't, sorry.
I am very very far away from browser-specific/CSS/BOM things (thanks to qooxdoo I never really had to be close to that 👍 ), so I have to ask you guys to really fix it

By the way: I think you should not change the "css.placeholder" detection, it is correct (IE has this feature/attribute).
What is wrong is that IE emits events that it shouldn't.
I would more think of a "has.problems.with.placeholder" kind of detection logic 😉, but it's up to you

@level420
Copy link
Member

From a short test http://tinyurl.com/zh8bvyt it seems that when the input field gets the first focus and the placeholder disappears, the value of the input field changes from null to an empty string. We could maybe prevent this by initializing the value of the input tag to an empty string?

@level420
Copy link
Member

According to this post https://connect.microsoft.com/IE/feedback/details/856700/ie11-ie10-send-input-events-at-times-when-it-is-not-appropriate microsoft will never fix this in IE11 as Edge is the new browser. There will only be security fixes for IE11 for the future.

@schnepe2
Copy link
Contributor Author

schnepe2 commented Jun 30, 2016

We could maybe prevent this by initializing the value of the input tag to an empty string?

I'll be happy to try in my applications code to check if it's enough.
In my application setting and removing of the value is common (not 100% recreated in the playground example). I could test if a proposed fix works when appearing and disappearing of the placeholder is done.
Can you provide a hint where to put what?

@hkollmann
Copy link
Member

var input = new qx.ui.form.TextField().set({
width: 200, placeholder: "placeholder text", liveUpdate: true
});
var info = new qx.ui.form.TextArea().set({
width: 200, height: 400, readOnly: true
});

input.addListener("changeValue", function (e) {
var value = e.getData();
var old = e.getOldData();
if(value === null) {
value = '---null---';
}
if(value === undefined) {
value = '---undefined---';
}
if(value === '') {
value = '---empty string---';
}
info.setValue( (info.getValue()||"") + "changedValue:|" + old + "|" + value + "|\n" );
}, this);

var doc = this.getRoot();
doc.add(input, {top: 5, left: 5});
doc.add(info, {top: 35, left: 5});

@hkollmann hkollmann reopened this Mar 11, 2020
@hkollmann
Copy link
Member

Only IE11 Problem

hkollmann added a commit that referenced this issue Mar 14, 2020
#9895)

* fix for #9070: Input event triggered on Internet Explorer when placeholder changed
@hkollmann
Copy link
Member

Done with #9895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Errors
Projects
None yet
Development

No branches or pull requests

4 participants