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

fix(ngModel): use paste/cut events in IE to support context menu #2203

Closed

Conversation

markdalgleish
Copy link
Contributor

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

@markdalgleish
Copy link
Contributor Author

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.

@markdalgleish
Copy link
Contributor Author

Has anyone had a chance to look at this? @mhevery @IgorMinar

@ghost ghost assigned jbdeboer Apr 11, 2013
@jbdeboer
Copy link
Contributor

It should be possible to write a test for this code. What have you tried?

@jbdeboer
Copy link
Contributor

  • Contributor signed CLA now or in the past (if you just signed, leave a comment here with your real name)
  • PR doesn't introduce new api
  • PR doesn't contain a breaking change
  • PR contains unit tests
  • PR contains e2e tests (if suitable)
  • PR contains documentation update (if suitable)
  • PR passes all tests on Travis (sanity)
  • PR passes all tests on ci.angularjs.org (cross-browser compatibility)
  • PR is rebased against recent master
  • PR is squashed into one commit per logical change
  • PR's commit messages are descriptive and allows us to autogenerate release notes (required commit message format)
  • All changes requested in review have been implemented

@markdalgleish
Copy link
Contributor Author

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;
});
Copy link
Contributor

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
@markdalgleish
Copy link
Contributor Author

I've cleaned up the test based on @petebacondarwin's feedback, no longer restoring the mocked 'hasEvent' function.

@petebacondarwin
Copy link
Contributor

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.

@petebacondarwin
Copy link
Contributor

Landed at: 363e4cb.
Thank you Mark for a really tidy Pull Request.

@markdalgleish
Copy link
Contributor Author

No problem, it was my pleasure. Thanks for merging it in :)

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

Successfully merging this pull request may close these issues.

Input ng-model fails to update on paste event in IE
3 participants