re-com icon indicating copy to clipboard operation
re-com copied to clipboard

Add a placeholder to datepicker-dropdown

Open p-himik opened this issue 8 years ago • 3 comments

Similar to HTML input's placeholder attribute. I think all that's needed is a new parameter description to datepicker-dropdown-args-desc and a corresponding argument to anchor-button.

p-himik avatar Nov 01 '16 18:11 p-himik

Could you elaborate on this (or provide a PR)? Do you want to place something like "Enter date" there? I'm wondering why this is better than just providing a default date to model. In which case, would you seed model with nil? So when they open the calendar, what date would they see? No date or today's date? If today's date, I presume you would immediately feed that into model?

Our general philosophy is to never leave a component in an undefined or invalid state.

Gregg8 avatar Nov 24 '16 07:11 Gregg8

Sure, I'll provide a PR when and if we have an agreement on how to implement it (if at all). Yes, something like "Enter date". In my particular case, I have two date fields in a small space with placeholders "From" and "Till". The default date says nothing about semantics. While one, of course, can provide an external label, it's not always an optimal solution (e.g. not coherent with other design elements, or tight space requirements). Yes, the model would be nil, maybe also an empty string (value of a not filled date input in Google Chrome is an empty string). When you open the calendar, you'd see no date selected, and maybe a small hint on the current day (again, just as Google Chrome shows date input).

In my understanding, nil is not an undefined state - it's the state without any date selected. The parameter :model can be explicitly set to nil - nothing undefined about it, in my opinion.

p-himik avatar Nov 24 '16 14:11 p-himik

@kimo-k @Gregg8 In our apps-lib variant(s) I had a similar usecase. The dropdown date range picker (also using a from and to with 2 pickers) is used as a filter criteria in which context it is optional to specify, hence :model is nil and in my specific example I wanted to show "Include all dates" in the label. I implemented a parameter :label-when-none with a default of an empty string, so that it behaves as normal for backward compatibility. What do we feel about this approach ?

hipitihop avatar Jan 31 '24 03:01 hipitihop