We've found an issue where events don't render correctly if the store data is changed whilst the scheduler isn't visible. We have reproduced this in the Salesforce environment, please see the following video:
The code in this scenario is very vanilla, there are no customisations. The scheduler is preloaded with some data in the front-end, and the button sends an event to the scheduler via Lightning Messaging Service. The event contains additional data which is then added to the scheduler event store. This is reproducible on the latest versions of Firefox and Chrome.
Hello.
I can see a problem in the video. Could you please provide more info about this setup? You told you're using basic config from our doc and then send some data to the scheduler. Please share a code snippet that you use to do that. Also, the data that you pass to the scheduler, is that a regular JS objects or instances of salesforce records?
Long story short, when LWC gets out of the view locker service reports its height as 0. And when you assign new events/resources in the next tab you force refresh which now thinks that scheduler height is 0. That's why you see a subset of events.
To fix this, you will have to refresh scheduler when it becomes visible again (when you navigate back to the tab). Unfortunately there's no public API to update the size, so options are:
Render rows twice. This API is public and gets job done, although it renders events twice which is far from optimal
scheduler.renderRows()
scheduler.renderRows()
Refer to the private API until we get you proper public one:
Thanks for looking into this.
Unfortunately, I don't believe there is any way of knowing when tabs are switched on a lightning page in Salesforce. I think this is a platform limitation. If you know of a way then that would be very useful!
import { LightningElement, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
export default class Bla extends LightningElement {
@wire (CurrentPageReference)
setCurrentPageReference(pageRef) {
// TODO: react to page reference change
}
}
This doesn't work for switching tabs on a lightning page (e.g. switching between the Scheduler and Button tabs in the video linked in the original post). It fires once when the tab is first loaded, but not each time. I think it's used for switching lightning tabs, which is not the same as tabs on a lightning page.