-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add today btn #486
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
feat: add today btn #486
Conversation
src/coalesce-vue-vuetify3/src/components/input/c-datetime-picker.vue
Outdated
Show resolved
Hide resolved
src/coalesce-vue-vuetify3/src/components/input/c-time-picker.vue
Outdated
Show resolved
Hide resolved
src/coalesce-vue-vuetify3/src/components/input/c-datetime-picker.vue
Outdated
Show resolved
Hide resolved
src/coalesce-vue-vuetify3/src/components/input/c-datetime-picker.vue
Outdated
Show resolved
Hide resolved
src/coalesce-vue-vuetify3/src/components/input/c-datetime-picker.vue
Outdated
Show resolved
Hide resolved
src/coalesce-vue-vuetify3/src/components/input/c-datetime-picker.vue
Outdated
Show resolved
Hide resolved
src/coalesce-vue-vuetify3/src/components/input/c-time-picker.vue
Outdated
Show resolved
Hide resolved
|
|
…er.vue Co-authored-by: Andrew Scott <[email protected]>
…vatt/next/today-btn
src/coalesce-vue-vuetify3/src/components/input/c-datetime-picker.vue
Outdated
Show resolved
Hide resolved
| v-bind="datePickerProps" | ||
| > | ||
| <template v-slot:actions v-if="showTodayButton"> | ||
| <v-btn @click="setToday" :disabled="!isDateAllowed(new Date())"> Today </v-btn> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking if today's date is allowed... is just passing 'new Date()' here sufficient? Is there any worry about time zones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would certainly be easier to not do this. Leave it up to the developer to just not enable the "Today" button if they know for their use case that selecting today will be out of bounds of their validation rules.
This validation is happening before the timezone transformations has been applied, so yes, there will be timezone issues here. The other usage of isDateAllowed in emitInput occurs after timezone transformations.
| <v-text-field | ||
| v-else | ||
| class="c-datetime-picker" | ||
| :class="{ 'today-btn': showTodayButton }" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unusual class name. The entire component is not a today-btn. Only the button itself inside the component's menu would make sense to have a today-btn class.
Consider a more appropriate class name like c-datetime-picker__menu--has-today-btn on the menu's contentClass, which also adheres to the (mildly consistent) use of BEM selectors in this project.
3f3c313 to
ae5e482
Compare
| } | ||
| } | ||
| function isDateAllowed(date: Date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should just be axed and if you click 'today' when there is a min/max value and today doesn't fall within it we just clamp to be within the bounds?
f14ec98 to
7375921
Compare
Description
Questions:
Ensure that your pull request has followed all the steps below: