Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

refactor(datepicker): implement ng-if on datepicker-popup #3666

Closed
wants to merge 1 commit into from
Closed

refactor(datepicker): implement ng-if on datepicker-popup #3666

wants to merge 1 commit into from

Conversation

RobJacobs
Copy link
Contributor

Implementing ng-if on the datepicker-popup directive for performance.

Closes #1915

@RobJacobs RobJacobs added this to the 0.13.1 (Performance) milestone May 13, 2015
@RobJacobs RobJacobs self-assigned this May 13, 2015
@JohannesRudolph
Copy link

+1

@rvanbaalen
Copy link
Contributor

Looks like some solid work @RobJacobs. I'll go ahead and merge this in asap.

Implementing ng-if on the datepicker-popup directive
for performance.

Closes #1915
Closes #3666
@@ -161,9 +161,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
$scope.keys = { 13:'enter', 32:'space', 33:'pageup', 34:'pagedown', 35:'end', 36:'home', 37:'left', 38:'up', 39:'right', 40:'down' };

var focusElement = function() {
$timeout(function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change required to pass tests? This seems like a behavior change for the keydown actions below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw #3705 . It would be good to either separate out this change to fix that particular issue, or to specify in this commit message the reason for this change that's unrelated to implemented ng-if .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisirhc This PR does not include #3705 suggested changes. I moved the $timeout wrapping the focus() call to the isOpen watch and wrapped the datepicker.focus broadcast with it. This was necessary as the datepicker popup now needs a digest cycle to render with ng-if and will provide a better indication of when the datepicker is ready for focus. Otherwise self.element[0] was not in the DOM yet.

I would like to move the document click binding into that same timeout, but will submit another PR for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change - this is only an issue for the popup, so the $timeout should only be in the popup itself.

@wesleycho
Copy link
Contributor

This LGTM.

@RobJacobs RobJacobs closed this in b72efed Jul 19, 2015
@RobJacobs RobJacobs deleted the datepicker-ngif branch July 20, 2015 11:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants