Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

datepicker scroll mask fails when datepicker is inside a modal #8177

Closed
ghost opened this issue Apr 22, 2016 · 1 comment
Closed

datepicker scroll mask fails when datepicker is inside a modal #8177

ghost opened this issue Apr 22, 2016 · 1 comment
Assignees
Labels
has: Pull Request A PR has been created to address this issue P4: minor Minor issues. May not be fixed without community contributions. type: bug

Comments

@ghost
Copy link

ghost commented Apr 22, 2016

DatePicker's have an associated md-scroll-mask, z-index=50, which blocks scrolling of the background while the dp is open. DatePicker's have z-index=100. However, modals have z-index 50 < z < 99. A datepicker inside of a modal will not prevent scrolling in the modal funky stuff happens.

Sample: http://codepen.io/beezus/pen/grjMQV

Here's what I did to make this work for now. I overrode and inherited the dp directive and updated the mask's z-index. I didn't dig deep enough to see how all of these things work to devise a better solution.

angular
  .module('material.components.datepicker')
  .directive('mdDatepicker', function() {
      return {
          restrict: 'E',
          require: [
            '?mdDatepicker'
          ],
          link: function(scope, iElm, iAttrs, controllers) {
              var datePickerCtrl = controllers[0];

              scope.$watch(
                function() {
                    return datePickerCtrl.isCalendarOpen
                },
                function(isCalOpen) {
                    var mask = document.querySelector('.md-scroll-mask');
                    if (mask) {
                        mask.style.zIndex = (isCalOpen ? '99' : '50');
                    }
                }
              );
          }
      };
  });
@crisbeto
Copy link
Member

Thanks for the report, I could reproduce it as well.

@crisbeto crisbeto self-assigned this Apr 22, 2016
@crisbeto crisbeto added this to the - Backlog milestone Apr 22, 2016
@crisbeto crisbeto added the P4: minor Minor issues. May not be fixed without community contributions. label Apr 22, 2016
crisbeto added a commit to crisbeto/material that referenced this issue May 1, 2016
* Fixes the datepicker not blocking scrolling when it is used within a dialog.
* Moves the `.md-scroll-mask` z-index to the SASS files since the old value was being set with JS for no apparent reason and made it harder to override.
* Adds a variable for the datepicker's z-index, since it was using the one for the menu.

Fixes angular#8177.
@crisbeto crisbeto added the has: Pull Request A PR has been created to address this issue label May 1, 2016
@Splaktar Splaktar removed this from the - Backlog milestone Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has: Pull Request A PR has been created to address this issue P4: minor Minor issues. May not be fixed without community contributions. type: bug
Projects
None yet
Development

No branches or pull requests

2 participants