-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngModel): use paste/cut events in IE to support context menu #2203
fix(ngModel): use paste/cut events in IE to support context menu #2203
Conversation
Note: I attempted to automate a test for this but it's such a crazy IE+mouse specific edge case I'm not sure how to do it. If anyone has any ideas on how to write a test, I'd be happy to add one. |
Has anyone had a chance to look at this? @mhevery @IgorMinar |
It should be possible to write a test for this code. What have you tried? |
|
I managed to write a couple of unit tests for this fix. Let me know if they're satisfactory. |
afterEach(function() { | ||
// Restore original 'hasEvent' | ||
$sniffer.hasEvent = hasEvent; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to restore the mocked event as the whole injector and all its services are recreated on each test.
In IE the model is not updated when the input value is modified using the context menu, e.g. pasting from the clipboard, or cutting all or part of the current value. To capture these changes, we bind to the proprietary 'paste' and 'cut' events. Closes angular#1462
I've cleaned up the test based on @petebacondarwin's feedback, no longer restoring the mocked 'hasEvent' function. |
Magic! Thanks for this fix. Right now the ci server is failing for some unknown reason I don't think it is the fault of this PR but I want to get that sorted before I merge. |
Landed at: 363e4cb. |
No problem, it was my pleasure. Thanks for merging it in :) |
In IE the model is not updated when the input value is modified using the context
menu, e.g. pasting from the clipboard, or cutting all or part of the current value.
To capture these changes, we bind to the proprietary 'paste' and 'cut' events.
Closes #1462