twinssbc / Ionic2-Calendar

A calendar component based on Ionic framework
https://ionic-calendar-demo.stackblitz.io
MIT License
388 stars 197 forks source link

Selecting the month view triggers #286

Closed markeames closed 6 years ago

markeames commented 6 years ago

Using the demo https://twinssbc.github.io/Ionic2-Calendar/demo/

If you select the day or week view - the mode only changes

If you select the month view - the onTimeSelected function gets run onTimeSelected(ev) { console.log('Selected time: ' + ev.selectedTime + ', hasEvents: ' + (ev.events !== undefined && ev.events.length !== 0) + ', disabled: ' + ev.disabled); }

Select the month view and you see the console output - but not for week or day view.

Why is the onTimeSelected function being run by just changing the mode to month, it correctly does not do this for either day or week?

Many thanks

twinssbc commented 6 years ago

@markeames When switching to a month view, there could be a date being selected explicitly, and you can see that date is highlighted. In weekview and dayview, you could only select a time and nothing get highlighted, so no need trigger onTimeSelected function. Even if onTimeSelected function has to be triggered, which hour should it trigger on? This method is not disabled in weekview and dayview. You could trigger it by explicitly select a slot.

markeames commented 6 years ago

Hey, thanks so much for the response. My challenge was I was getting recursion because I was updating the calendar date in the onTimeSelected which would call onViewTitleChanged which would call onTime Selected etc. It was ok in the day and week view but not the month view. Appreciate your response and I see the logic. I have stopped updating the calendar date in the onTimeSelected function so that clears up the functionality.