[6.x] Date picker today shortcut#14651
Conversation
…today" to orient yourself, and then use "apply" to escape the calendar easily
… select, today's date becomes the first selection
…date to the correct month
…elect, but pick another day, "select" should reset to "today"
… you should not be able to select today
|
Hmmm, I've only just noticed that the "clear" It's not quite the same because if the field is not required, then clearing it will not focus on today's date. I wonder if it's possible to copy the button and make a few modifications rather than make all these changes, if you don't like the amount of lines changed @jasonvarga. I kind of want to reach for a "today" button because it's a more obvious affordance than mentally clearing the field in order to focus on today's date. |
|
Why don't we just have a "Today" button and make it disabled when "today" is picked. Avoid all the "change the button to apply" logic. Hide it if the earliest/latest dates make today outside that range. |
|
@jasonvarga I had a better idea and updated 😃 |
A computed with no reactive deps memoizes its first value for the lifetime of the component, so the "This month" shortcut would jump to yesterday's month if the calendar stayed open across midnight. Read now() lazily at each call site instead.
opacity-40 is color-mode-independent so dark:disabled:opacity-40 is a no-op. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Calendar.vue was reaching up to DatePickerRoot / DateRangePickerRoot context to drive its today button — an awkward cross-tree coupling. Move the button into CalendarToday.vue, rendered inside the CalendarRoot slot, so it can inject CalendarRootContext / RangeCalendarRootContext directly. Wire it through the components map like Prev/Next so addons can override it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Description of the Problem
If you're dealing with an old date and want to change it, it can be a bit of mental effort to find / re-orient yourself to today's date.
What this PR Does
Before (inline)
Here you can see the calendar is slightly misaligned to the right – for example, you can see
28is closer to the right here vs22After (inline)
With "today" button and alignment fixed
How to Reproduce
(blueprint below)
Here's the sidebar bit of a blueprint with various configurations to help: