Problem/Motivation

In Drupal 7 we were able to place two Timelines on the same page without issues. Since upgrading to Drupal 10, we have been unable to load the second timeline.

Steps to reproduce

Place two Views Timeline blocks on the same page, only the first one will render the timeline.

Proposed resolution

When I debugged this issue, there was only data for one block in the drupalSettings variable. It seems that when the data is being prepared inside template_preprocess_views_timelinejs_view_timelinejs(), the attached data is not being preserved.

This is an indexed array. When I change this to use the ID for each array key, the data for both blocks comes through into drupalSettings.

I will create an issue fork and merge request shortly. This will contain the changes to the template_preprocess hook and to the Javascript.

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

akoepke created an issue. See original summary.

akoepke’s picture

akoepke changed the visibility of the branch 4.x to hidden.

akoepke’s picture

I have put together a demo of the issue using the Umami demo profile.

The test site is using the latest release of the module, the dev site has the fixed code from this issue fork.

https://test-views-timelinejs.pantheonsite.io/en/tags/vegan
https://dev-views-timelinejs.pantheonsite.io/en/tags/vegan

Both sites are using Timeline.js loaded from NU Knight Lab CDN - version 3.8.18.

akoepke’s picture

Status: Active » Reviewed & tested by the community
akoepke’s picture

Accpeting this merge request will also apply the fix from #3400707: Use Drupal Behaviours in JS

dcam’s picture

Title: Mutliple Timeline blocks on one page not supported » [regression] Mutliple Timeline blocks on one page not supported
Version: 4.1.0 » 4.x-dev
Status: Reviewed & tested by the community » Needs review

  • dcam committed 73f0c5c2 on 4.x authored by akoepke
    Issue #3507380 by akoepke, dcam: [regression] Mutliple Timeline blocks...
dcam’s picture

Status: Needs review » Fixed

Thanks for working on this!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.