Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls to re-render resources while selecting/dragging/resizing leads to error #4817

Closed
notajingoist opened this issue Jan 8, 2016 · 7 comments

Comments

@notajingoist
Copy link

I have run into a bug where calling any method that re-renders resources (refetchResources, etc.) while in the middle of performing a selection/drag/resize (at least these) leads to the following error (stack trace included):

Uncaught TypeError: Cannot read property 'length' of null

FC.CoordCache.Class.extend.getHorizontalIndex @ fullcalendar.js:2122
FC.TimeGrid.Grid.extend.queryHit @ fullcalendar.js:6340
DragListener.extend.queryHit @ fullcalendar.js:2784
DragListener.extend.drag @ fullcalendar.js:2709
FC.DragListener.Class.extend.mousemove @ fullcalendar.js:2341
(anonymous function) @ fullcalendar.js:942
n.event.dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3

I think what's happening is that when I re-render, the original colCoordCache object is reinitialized in the renderDates function but the query hits are still happening and so this check for length on colCoordCache.left (which is now null) results in this error.

The reason this is a problem for me is that I am working with a live-updating asynchronous data model that continuously pushes updates from the server to the client. This means that at any point, I might need to re-render the resources if they change on the server. And because these live updates are unpredictable, they may happen while a user is selecting some part of the scheduler, or dragging/resizing an event.

To work around this, I tried to set a flag to indicate when the scheduler is "busy," i.e. not safe to re-render resources, but the API doesn't include callbacks that fire at the very start of each of these interactions. eventDragStart is OK, but select and eventResize don't actually fire until after a selection and resize are completed (mouse click is released), and that is too late. (Although I would rather this bug be fixed than have a change to the API to provide more useful callbacks).

I've simulated this bug on jsbin (http://jsbin.com/kavowocufo/edit?js,output) by making a call to refetchResources every 1000 milliseconds. Open up the console, and start selecting parts of the scheduler/dragging events/resizing events and observe the above error get logged.

@notajingoist
Copy link
Author

Hi there @arshaw, was just wondering if you ever got around to taking a look at this issue? I am still experiencing this, and was hoping to get your feedback on it (whether it's worth fixing, and if so, your estimate on when the fix would go in). Thanks!

@arshaw
Copy link
Member

arshaw commented May 13, 2016

Hi @notajingoist I have not had a chance to dig into it unfortunately. Thank you for the repro link. There are some other more urgent bugs that need fixing in the meantime, but this is on my radar

@arshaw
Copy link
Member

arshaw commented May 30, 2016

Thanks for the clear explanation and diagnosis. I can see why this would be happening.

The code is currently not very well set up to rerender anything mid-drag. I understand your usecase here, but can't imagine it is too common, so apologize in advance if this takes a little while to formally address.

What I would recommend, if you'd like to get your hands dirty, is to somehow re-generate the coord cache if it happens to be null. It would function as a lazy cache.

@notajingoist
Copy link
Author

I'm not sure what changed, but I just did a big upgrade of the scheduler (1.2.0 to 1.5.0) and I don't think this issue is relevant anymore. Not sure which release fixed this.

See new demo (with upgraded fullcalendar & scheduler): http://jsbin.com/yeyinekoba/1/edit?js,output

However, I did notice a new symptom: the jsEvent argument in at least eventResizeStop (maybe for other resize/drag/select/etc. callbacks as well, but didn't try) is undefined when you resize (and probably drag/select/etc.) during a resource re-render. I've included a console.warn of the jsEvent value in the eventResizeStop callback in my demo link (open up your browser's developer console) to illustrate this issue. For comparison, here is a demo with the older version of the library where jsEvent is always defined http://jsbin.com/nujifaqijo/edit?js,output

This is of course a very minor issue; I was just relying on jsEvent always being defined, which is why I found this bug, but I can work around that myself pretty easily. Not sure if it points to any larger issues though, or if this is actually the expected behavior.

@arshaw arshaw transferred this issue from fullcalendar/fullcalendar-workspace Jul 30, 2019
@arshaw
Copy link
Member

arshaw commented Jun 24, 2020

this is no longer an issue: https://codepen.io/arshaw/pen/abdwvON?editable=true&editors=001

@arshaw arshaw closed this as completed Jun 24, 2020
@ickphum
Copy link

ickphum commented Jul 29, 2020

Hi Adam. Re your comment "no longer an issue", does this assume v5 is in use?
Thanks.

@arshaw
Copy link
Member

arshaw commented Jul 29, 2020

exactly. i forgot to clarify that. the problem is fixed, only in v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants