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.
Issue fork views_timelinejs-3507380
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
Comment #2
akoepke commentedComment #5
akoepke commentedI 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.
Comment #6
akoepke commentedComment #7
akoepke commentedAccpeting this merge request will also apply the fix from #3400707: Use Drupal Behaviours in JS
Comment #8
dcam commentedComment #10
dcam commentedThanks for working on this!