nhn / tui.calendar

🍞📅A JavaScript calendar that has everything you need.
http://ui.toast.com/tui-calendar
MIT License
11.88k stars 1.28k forks source link

afterRenderEvent not fired when in readonly mode #1327

Closed stan5521 closed 1 year ago

stan5521 commented 1 year ago

Version

TOAST UI Calendar 2nd Edition @version 2.1.3

Test Environment

Browser: Chrome Version 108.0.5359.99 (Official Build) (64-bit)

Current Behavior

When using the calendar in readonly mode the afterRenderEvent is not fired when redering events, this is the code i use:

const app = calendar.querySelector(".tui-main-calendar");

calendar.tuiCalendar = new tui.Calendar(app, {
    defaultView: 'month',
    disableDblClick: true,
    usageStatistics: false,
    useDetailPopup: false,
    useFormPopup: false,
    isReadOnly: true,
    month: {
        startDayOfWeek: 1,
        dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
    },
    theme: {
        common: {
            holiday: {
                color: 'black',
            },
        },
        month: {
            holidayExceptThisMonth: {
                color: 'rgba(51, 51, 51, 0.4)',
            },
        },
    }
});

calendar.tuiCalendar.on('afterRenderEvent', (eventObj) => {
    console.log(eventObj);
});

calendar.tuiCalendar.createEvents([
    {
        id: 'event3',
        calendarId: 'cal2',
        title: 'Vacation',
        start: '2022-12-27',
        end: '2022-12-27',
        description: "Deze periode hebben we vacantie",
        isAllday: true,
        category: 'allday',
    },
    {
        id: 'event3',
        calendarId: 'cal2',
        title: 'Vacation',
        start: '2022-12-29',
        end: '2022-12-29',
        description: "Deze periode hebben we vacantie",
        isAllday: true,
        category: 'allday',
    },
]);

When i switch isReadOnly to false it will output 2 events in the console. When isReadOnly is true it will not log anything.

Expected Behavior

I couldn't find anything in the docs about this event not working in read only mode (some other events in the docs do state isReadOnly: false is needed). But the events that need isReadOnly: false are mostly events that only happen when editing/changing/removing things which isn't posible in read only mode so it makes sense. I think there are many use cases where you want the read only mode in combination with this event.

adhrinae commented 1 year ago

@stanverbakel

Thanks for the report. Apparently, this condition should be changed to isNil(resizingWidth) && isNil(movingLeft). Note that this bug appears only for events in the monthly view and all-day events in the weekly view.

Please understand I can guarantee the release date of the patch.

stan5521 commented 1 year ago

Thanks! I will edit the source files and rebuild so i can use your solution until there is a version released with this fix. Thanks for your fast reply and fix.