Hi,
I am not sure if this can regarded as a bug. It depends a bit on your mission-statement...
Steps to reproduce:
- Create an input-field with a standard value-binding.
- Create a button with a click-binding.
- Drag and drop a text from another window into the text-field.
- Click the button
Result:
The text dropped to the input-field is NOT in the observable.
This happens at least in Chrome and Firefox on Windows 7.
Why does this happen?
The change-event does not fire.
Should this be fixed?
Strictly speaking, knockout handles all events, it is designed to. But this kind of defeats the purpose of having a value-binding in the first place.
I really depends on the way you see knockout.
Is it just a fancy event-handler? Then don't fix it.
Is it a library to handle user-inputs in a consistent manner? It should probably be fixed.
I can think of two ways to fix this:
1.) Just patch the current value-binding by registering an additional event-listener (insert the code below line 4892 in version 3.4.1, that's what we did):
if (eventName === "change") {
ko.utils.registerEventHandler(element, "input", function () {
if (element !== document.activeElement) {
handler();
}
});
}
2.) Define a new valueUpdate-event (like "changeAndFocusLost") that fixes the weaknesses of the change-binding.
Regards
Andreas