Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no option to close input-date on select #196

Open
jacek213 opened this issue Oct 19, 2016 · 3 comments
Open

no option to close input-date on select #196

jacek213 opened this issue Oct 19, 2016 · 3 comments

Comments

@jacek213
Copy link

As stated in the title. I'm aware that it's the default behaviour of pickadate provided by materialize and I know it can be hacked by closing it in onSet function with jquery, but it would be nice if it was configurable option, especially considering the fact that that's the way the "clean" pickadate works by default.

@jacek213
Copy link
Author

If anyone is facing the same issue, here is my workaround (based on solution for core materialize lib - Dogfalo/materialize#870 (comment)):

(function() {
  'use strict';

  angular
    .module('myappmodule')
    .directive('inputDate', inputDate);

  // this decorator enables new option: closeOnSelect -> false by default

  /** @ngInject */
  function inputDate() {
    var directive = {
      link: link
    };

    return directive;

    function link(scope, elem, attrs) {
      if (attrs.closeOnSelect) {
        elem.pickadate({
          onSet: function(arg){
            if ('select' in arg){ //prevent closing on selecting month/year
              this.close();
            }
          }
        });
      }
    }
  }

})();

@ghost
Copy link

ghost commented Dec 15, 2016

Please see this PR: Dogfalo/materialize#4003 that shows how to fix without the hacky workaround.

@webbiesdk
Copy link
Collaborator

I think we'll wait and see if Dogfalo/materialize#4003 gets merged, and if it does, then that makes our implementation much easier.

Until then, others can use the workaround.

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

No branches or pull requests

2 participants