Skip to content

Commit

Permalink
fix: prevent faulty event bubbling when clicking on month day event (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelR1998 authored Dec 1, 2023
1 parent f1ae1dd commit ca95519
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/month/Day.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'is-selected': isSelected,
'is-today': isToday,
}"
@click="emitDayWasClicked"
@click.self="emitDayWasClicked"
@dragleave="handleDragLeave"
@dragover="handleDragOver"
@drop="handleDrop"
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/components/month/Day.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ describe("Day.vue", () => {
expect(underTest.emitted("date-was-clicked")[0][0]).toBe("2022-05-23");
});

it('should not emit "date-was-clicked" when an event is clicked', () => {
const underTest = day({ props: defaultProps });
const dayEvent = underTest.find(".calendar-month__event");

dayEvent.trigger("click");

expect(underTest.emitted("date-was-clicked")).toBeFalsy();
})

it('should not emit custom event "day-was-selected" when qalendar !isSmall and a day is clicked', async () => {
const underTest = day({ props: {
...defaultProps,
Expand Down

0 comments on commit ca95519

Please sign in to comment.