Skip to content

Commit

Permalink
fix(datepicker): md-open-on-focus constantly re-opens on close w/ IE11 (
Browse files Browse the repository at this point in the history
angular#11440)

<!-- 
Filling out this template is required! Do not delete it when submitting a Pull Request! Without this information, your Pull Request may be auto-closed.
-->
## PR Checklist
Please check that your PR fulfills the following requirements:
- [x] The commit message follows [our guidelines](https://github.com/angular/material/blob/master/.github/CONTRIBUTING.md#-commit-message-format)
- [ ] Tests for the changes have been added or this is not a bug fix / enhancement
- [x] Docs have been added, updated, or were not required

## PR Type
What kind of change does this PR introduce?
<!-- Please check the one that applies to this PR using "x". -->
```
[x] Bugfix
[ ] Enhancement
[ ] Documentation content changes
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Infrastructure changes
[ ] Other... Please describe:
```

## What is the current behavior?
- md-open-on-focus constantly re-opens on close w/ IE11
    - we don't want `$mdUtil.nextTick`'s batching features in this case
        - especially on a low performance or heavily loaded device

<!-- Please describe the current behavior that you are modifying and link to one or more relevant issues. -->
Issue Number: 
Fixes angular#10999

## What is the new behavior?
- Use `$timeout` instead of  `$mdUtil.nextTick`.
    - Datepicker is no longer re-opened constantly when closed on IE11.

## Does this PR introduce a breaking change?
```
[ ] Yes
[x] No
```
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->
<!-- Note that breaking changes are highly unlikely to get merged to master unless the validation is clear and the use case is critical. -->

## Other information
  • Loading branch information
Splaktar authored and mmalerba committed Sep 21, 2018
1 parent edb9733 commit 6596cc7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/datepicker/js/datepickerDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@
*
* @ngInject @constructor
*/
function DatePickerCtrl($scope, $element, $attrs, $window, $mdConstant,
$mdTheming, $mdUtil, $mdDateLocale, $$mdDateUtil, $$rAF, $filter) {
function DatePickerCtrl($scope, $element, $attrs, $window, $mdConstant, $mdTheming, $mdUtil,
$mdDateLocale, $$mdDateUtil, $$rAF, $filter, $timeout) {

/** @final */
this.$window = $window;
Expand All @@ -264,7 +264,7 @@
/** @final */
this.$mdConstant = $mdConstant;

/* @final */
/** @final */
this.$mdUtil = $mdUtil;

/** @final */
Expand All @@ -273,6 +273,9 @@
/** @final */
this.$mdDateLocale = $mdDateLocale;

/** @final */
this.$timeout = $timeout;

/**
* The root document element. This is used for attaching a top-level click handler to
* close the calendar panel when a click outside said panel occurs. We use `documentElement`
Expand Down Expand Up @@ -833,7 +836,7 @@
// in IE when md-open-on-focus is set. Also it needs to trigger
// a digest, in order to prevent issues where the calendar wasn't
// showing up on the next open.
self.$mdUtil.nextTick(reset);
self.$timeout(reset);
} else {
reset();
}
Expand Down

0 comments on commit 6596cc7

Please sign in to comment.