Calendar view refreshes and jumps to current month on any ajax update

Created on 23 November 2022, about 2 years ago
Updated 3 April 2023, over 1 year ago

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.

๐Ÿ› Bug report
Status

Postponed: needs info

Version

5.1

Component

Code

Created by

๐Ÿ‡น๐Ÿ‡ทTurkey rgnyldz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mingsong ๐Ÿ‡ฆ๐Ÿ‡บ

    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?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shabana.navas

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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shabana.navas

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

  • Status changed to Closed: works as designed over 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mingsong ๐Ÿ‡ฆ๐Ÿ‡บ
  • Status changed to Active 5 months ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ecdani

    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.

  • 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!

  • Pipeline finished with Success
    3 months ago
    Total: 154s
    #286622
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines bryanmanalo

    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.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mingsong ๐Ÿ‡ฆ๐Ÿ‡บ

    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.

Production build 0.71.5 2024