Hi,
The application the I currently work on requires initial Scheduler timeline view to be set at a start of a current date.
To achieve that I use Bryntum's scheduler.scrollToDate built-in function.
Initially I've invoked that function during comonentDidMount event using useEffect hook.
But with this approach for some reason jumping to today does not work sometimes, approximately each 4-5 page reload.
So I assumed that it was happening because a comonentDidMount event, on which jumpToToday function is invoked, is being fired before an actual Event date is being populated to Scheduler timeline. Which causes a jumpToToday function to being called but bypass and not set the timeline view into today view in a result.
I've tried hooking into EventStore load event and some other event that was seem appropriate to me, but no success was achieved by doing so.
So I've implemented a hack:
- Attached ResizeObserver to a Scheduler container element
- Calling jumpToToday function once resize event occured with the delay of 300ms
I did that because a Scheduler container resize event is a strict sign of an Event data being populated into a timeline — once events get rendered, the size of Scheduler grows vertically.
BUT initially that produced the same effect. So I added additional 300ms setTimeout for calling jumpToToday function. And that finally seems to work.
But the problem is that the approach with the ResizeObserver and setTimeout set within in is bad and overcomplicates things.
What is the reason from this issue to happen?
And what are better solutions to that?
For clarity, I've attached an additional video briefing with the explanation of an issue.