bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

`syncCurrentTimeIndicator` throws an error if "today" is a hidden non working day #5333

Closed ExtAnimal closed 2 years ago

ExtAnimal commented 2 years ago

Forum post

When I try to set today's day (here it's Wednesday) as a non working day and hide it, I got this error: 'Uncaught TypeError: can't access property "appendChild", i is null' You can find a test case in file attachments.

ExtAnimal commented 2 years ago

The fix is this in DayView.js:

    syncCurrentTimeIndicator() {
        const
            me  = this,
            now = new Date(),
            dayElement  = me.getDayElement(now),
            {
                currentTimeIndicator,
                dayTime,
                endDate,
                startDate
            }   = me;

        if (startDate && endDate) {
            if (dayElement && DH.betweenLesser(now, startDate, endDate) && dayTime.contains(now)) {
                const
                    dayLengthMs = me.getDayLength('ms'),
                    nowMS       = dayTime.delta(now, 'ms');

                if (currentTimeIndicator.parentNode !== dayElement) {
                    dayElement.appendChild(currentTimeIndicator);
                }

                currentTimeIndicator.style.top = DomHelper.percentify(nowMS / dayLengthMs * 100);
            }
            else {
                currentTimeIndicator.remove();
            }
        }
    }