Count is added by 2, AJAX triggered twice per view on trigger.js

Created on 6 December 2023, about 1 year ago

Problem/Motivation

The trigger.js is triggered twice when bigpipe module is enabled.

Steps to reproduce

  1. Install fresh Drupal 10.1.6, Regular profile
  2. Download radioactivity 4.0.x-dev and admin_toolbar
  3. Enable module radioactivity, admin_toolbar, admin_toolbar_tools, big_pipe
  4. Go to page content type, create field field_radioactivity_count, set Energy Profile to count
  5. Set the field display, set field's emitter value to 1, and check to Display current energy value.
  6. Create a new node by content type page.
  7. View the node page
  8. Run cron by pressing the button from module admin_toolbar_tools, view image
  9. Every cron run by button click refreshes the page, and should only add 1 view to the node page, but the result is 2.

Proposed resolution

Use Once library to assure it is only triggered once per page reload.

https://www.npmjs.com/package/@drupal/once

See Drupal change record: https://www.drupal.org/node/3158256

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

🇹🇼Taiwan g-brodiei

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024