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

Datepicker Popups closing when selecting a month #4314

Closed
dwelch2344 opened this issue Aug 31, 2015 · 1 comment
Closed

Datepicker Popups closing when selecting a month #4314

dwelch2344 opened this issue Aug 31, 2015 · 1 comment

Comments

@dwelch2344
Copy link

I've got a strange scenario where clicking any of the buttons on the datepicker will close, which really isn't a problem unless you're trying to scroll through the months (or pick one explicitly). When this happens, the date picker doesn't actually trigger the cleanup method

I'm fairly confident it's something to do with my app / libraries, as I can't seem to replicate it on a clean project. However, I've been trying to debug why it's happening and am totally up a creek without a paddle.

One potential issue I came across while stepping through the events is that the documentClickBind function is being triggered and toggling the state, even if the event is inside the popup. It looks like line 718 is checking to see if the clicked element is inside the datepicker target, but in a popup's case it should probably also be a searching for a child of popupEl instead, correct?

Adjusting that line locally to the following fixes our issues, but I'm curious how this isn't also occurring in vanilla apps. Does the following make more sense as it's possible to click a custom element the popup that doesn't close the popup?

var documentClickBind = function(event) {
        if (scope.isOpen && !(element[0].contains(event.target) || popupEl[0].contains(event.target))) {
          scope.$apply(function() {
            scope.isOpen = false;
          });
        }
      };

An example of one of our datepickers:

<input type="text" class="form-control"
                               datepicker-popup="{{dp.format}}"
                               show-weeks="false"
                               show-button-bar="false"
                               is-open="__dp.reportStart"
                               ng-click="dpOpen($event,'reportStart')"
                               ng-model="report.startDate"
                               required/>
@wesleycho
Copy link
Contributor

If the event is inside the popup, it should not be bubbling up, due to the $event.stopPropagation call https://github.com/angular-ui/bootstrap/blob/master/template/datepicker/popup.html#L1 .

I am not quite sure the reason for this call.

That said, the proposed change doesn't seem to break anything, and passes all of the tests - it seems reasonable enough.

@wesleycho wesleycho added this to the 0.13.4 (Performance) milestone Sep 1, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants