Problem/Motivation

The calendar table display refreshes on any ajax update causing the calendar to jump to the current date or initial state. This is bad because if the user jumps between months they get pulled back to the initial (or current) month.

Steps to reproduce

Create a calendar view of any type. Visit page. Trigger any ajax task on the page. (Or let a module do recurring ajax calls)

- In my case I have the Simple less module and the private message module installed. Simple less has a live CSS refresh functionality which is kicking in ajax calls every 1 second. With that module active the calendar jumped back every second, when I close it there is also the private messages module which has a block for notifications that pulls ajax data every 10 seconds if there is a new message. So thats how I knew that this issue was triggered by an ajax call.

Proposed resolution

I'm not that much of an expert but I think; in the js/fullcalendar_view.js on line 367 there is a function that is called after ajaxComplete(). Since there are lots of things using ajax it would be best to restrict those functions to specific ajax events made by the calendar somehow.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

RgnYLDZ created an issue. See original summary.

kozakmaly’s picture

I can confirm this is an issue, before looking at this issue, the trail led me to this exact same block of code.

mingsong’s picture

Status: Active » Postponed (maintainer needs more info)

Do you still come across this issue with 5.1.11?
If so, what error / waring message in your Drupal log or in your browser console?
What version of Drupal core are you using?

shabana.navas’s picture

Yes, I'm running the latest version and am getting the same issue.

shabana.navas’s picture

Nevermind, that was due to custom code on my side.

mingsong’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
ecdani’s picture

Version: 5.1.7 » 5.1.13
Status: Closed (works as designed) » Active

This is still an issue, the module intercepts any jquery ajaxComplete event and resets the calendar.
Im using Drupal 10.2.7 and Fullcalendar_view 5.1.13. It doesn't show any error message or similar.

I think that this is a side effect of an intentional behavior.

The line 396 of js/fullcalendar_view.js intercepts every ajax call (related or not to the calendar), and destroys and recreates the calendar, resetting the navigation.

¿There are any potential solution or workaround?
Ty.

alan ridgway made their first commit to this issue’s fork.

alan ridgway’s picture

I made a change in the fork here to try and ensure that the only ajax that changes the calendar view comes from views ajax. I don't think it covers the entirety of the need here considering other views on the page sending ajax requests will still reload the calendar, but it's a start!

bryanmanalo’s picture

Added a patch to store the default date and view before any ajax call. Then reload those values on calendar rebuild/ajax complete.

Visually speaking, the redraw is not noticeable.

mingsong’s picture

From what I see, we got two proposed approaches so far.

@bryanmanalo, could you please create a new fork for your patch? We need the CI tests to make sure new changes won't create a regression bug.

If someone could create a new JavaScript functional test to reproduce this issue with CI, that would be great.

jmoreira made their first commit to this issue’s fork.

jmoreira’s picture

Status: Active » Reviewed & tested by the community

Patch #11 worked great for me.

mingsong’s picture

The automated test failed.

Back to need work.

mingsong’s picture

Status: Reviewed & tested by the community » Needs work
jmoreira’s picture

Status: Needs work » Needs review

Tests added and passing. Patch still works on my site.

mingsong’s picture

Please try the 5.3.x

This issue has been tested with that branch, it looks good to me.

Ajax call test

jmoreira’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new559.7 KB

Tested with 5.3:
- I've imported the test View and tested it without the patch: it goes back to current month.
- Works fine with the patch.

mingsong’s picture

Version: 5.1.13 » 5.3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Patched with 5.3.x.