Skip to content

Commit

Permalink
fix(VCalendar): forward all bound events to internal elements (#15592)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD authored Aug 9, 2022
1 parent 1e0a4ad commit 299330c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ describe('mouse.ts', () => {
const noop = e => e
const wrapper = mount(Mock, {
listeners: {
click: noop,
'click:foo': noop,
},
})

expect(typeof wrapper.vm.getDefaultMouseEventHandlers('', noop).click).toBe('function')
expect(typeof wrapper.vm.getDefaultMouseEventHandlers(':foo', noop).click).toBe('function')
expect(Object.keys(typeof wrapper.vm.getDefaultMouseEventHandlers('', noop))).toHaveLength(6)
})

Expand Down
17 changes: 8 additions & 9 deletions packages/vuetify/src/components/VCalendar/mixins/mouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ export default Vue.extend({

methods: {
getDefaultMouseEventHandlers (suffix: string, getEvent: MouseHandler): MouseEventsMap {
const listeners = Object.keys(this.$listeners)
.filter(key => key.endsWith(suffix))
.reduce((acc, key) => {
acc[key] = { event: key.slice(0, -suffix.length) }
return acc
}, {} as MouseEvents)

return this.getMouseEventHandlers({
['click' + suffix]: { event: 'click' },
...listeners,
['contextmenu' + suffix]: { event: 'contextmenu', prevent: true, result: false },
['mousedown' + suffix]: { event: 'mousedown' },
['mousemove' + suffix]: { event: 'mousemove' },
['mouseup' + suffix]: { event: 'mouseup' },
['mouseenter' + suffix]: { event: 'mouseenter' },
['mouseleave' + suffix]: { event: 'mouseleave' },
['touchstart' + suffix]: { event: 'touchstart' },
['touchmove' + suffix]: { event: 'touchmove' },
['touchend' + suffix]: { event: 'touchend' },
}, getEvent)
},
getMouseEventHandlers (events: MouseEvents, getEvent: MouseHandler): MouseEventsMap {
Expand Down

0 comments on commit 299330c

Please sign in to comment.