Make datepicker less opinionated
Actual behavior:
- What is the issue? md-datepicker forces the calendar icon, and the drop arrow with no way to style it otherwise. Also, the only way to open the popup is by clicking one of those icons.
- What is the desired behavior? make md-datepicker less opinionated. Allow the possibility to remove the default icons. Allow a way to open the popup programmatically. I should be able to open the datepicker popup any way I choose. Bootstrap has an is-open attribute on the directive to accomplish this, maybe something like that.
- Without the icons, how would the user know that it's a datepicker? If you really want to, you can remove them with CSS.
- Another way of opening it is via the alt+down keyboard combo.
- It's not necessarily a public API, but you can open the calendar by getting a hold of the datepicker controller:
var controller = angular.element(document.querySelector('md-datepicker')).controller('mdDatepicker');
controller.openCalendarPane({
target: controller.inputElement
});
Perhaps it could be more appropriate to have a scope listener on the datepicker to trigger an open (there's already one for closing it)?
For example: what if I want my date field to look like every other field in a form. I label it as a date (e.g. 'Start Date' or something), so the user knows it's going to be a date. When they click or tab into the field, I pop the picker. Sometimes the extra icons on both ends are just extra content that I don't necessarily want.
Of course I can remove the items with CSS, but it would be nice if it were just a config option. This is just a convenience.
The real issue though is the listener on the datepicker so it can be opened via code or in other ways. I could add my own "open" button, replace the icon, etc. and still be able to trigger the popup. As I mentioned, the is-open attribute Bootstrap offers seems to be a good compromise.
Alright, regarding opening on focus, there's an issue about it already and I'll try to get it sorted. Also I'd say an equivalent of is-open also makes sense, I'll see what I can do.
Thanks @crisbeto