Refactor the JavaScript for the widget to use the once library

Created on 22 May 2024, 11 months ago

Problem/Motivation

I noticed the JS for the widget isn't using the once() library. It's also using both the JS behaviors API combined with the jQuery document ready API which isn't really correct.

Since it registers a JS behavior, Drupal will re-invoke the code every time thee DOM loads initially, when BigPipe loads data, or when any other Drupal AJAX event takes place on the page. In my initial testing on a sample site, the behavior was executed 5 times, leading to all the event handlers being attached to DOM elements multiple times unnecessarily. This could lead to hard to debug issues in the future. It may even be a contributing factor to the problems encountered in πŸ› Office_hours Action links always point to frontpage on uncollapsed paragraphs Active

Steps to reproduce

Proposed resolution

It should be refactored to rely on the Drupal behaviors API only, and combined with the once() library to ensure that event handlers are only attached once to the DOM elements. Without this, the handlers are attached multiple times unnecessarily.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code - widget

Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

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