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

feat(VCalendar): add day click events #19728

Closed
wants to merge 1 commit into from

Conversation

muzychenka
Copy link

Description

it would be nice to be able to track clicking on a day in the calendar (to add a new event i.e.)
I added events monthDayClick for VCalendarMonthDay, dayClick for VCalendarDay and several events for VCalendar itself to handle all these clicks: click:monthDay, click:weekDay, click:day

Markup:

<template>
  <v-app>
    <v-container>
      <v-calendar
        view-mode="month"
        @click:day="click('Day', $event)"
        @click:month-day="click('Month', $event)"
        @click:week-day="click('Weekday', $event)"
      />
    </v-container>
  </v-app>
</template>

<script setup lang="ts">
function click (type: string, date: Date) {
  alert(`${type}: ${date}`)
}
</script>

@@ -36,6 +36,9 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
emits: {
next: null,
prev: null,
'click:monthDay': (value: Date) => true,
'click:weekDay': (value: Date) => true,
'click:day': (value: Date) => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these events should use any since we're using Date adapter and not all adapters using Date (onXXXClick functions should be also changed: check VDatePicker.tsx)

In fact, onClickToday is wrong:

    function onClickToday () {
      model.value = [new Date()]
    }

should be:

    function onClickToday () {
      model.value = [adapter.date()]
    }

I need to check if this is working:

imagen

@KaelWD
Copy link
Member

KaelWD commented May 1, 2024

Duplicate of #19568

@KaelWD KaelWD marked this as a duplicate of #19568 May 1, 2024
@KaelWD KaelWD closed this May 1, 2024
@JulienAramino
Copy link

Hello, could we have also click:time?

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

Successfully merging this pull request may close these issues.

None yet

4 participants