AJAX Compatibility, Accessibility and Duplicate ID issues

Created on 12 April 2022, about 2 years ago
Updated 27 November 2023, 7 months ago

Problem/Motivation

  1. When there is no shareable element present on the page the widget still gets rendered in the end of the body tag
  2. If there are more than one selector in the shareable element selectors list - the shareable popup gets duplicate-appended on the page at the end of the body tag
  3. When there are multiple AJAX requests the shareable element gets duplicate-appended on the page at the end of the body tag
  4. All sharer popups have duplicate ID
  5. Email link doesn't have

Steps to reproduce

  • Configure the module to have at least 2 selectors
  • Open a page that doesn't contain any elements that would match a listed selector: observe the sharer popup appended anyway
  • Open a page that does at least one extra Drupal.attachBehaviors call, say a page that has an AJAX call on it: observe the sharer popup re-appended anyway
  • In order to reproduce the accessibility issue - use an accessibility browser extension like for example WAVE tool. It will complain about the "Email" link being an empty link

Proposed resolution

  • Stop initializing the library for all selectors, wrap the initialization in more DOM checking.
  • Use "context" parameter and jquery.once library to isolate only new instances of selector
  • Only initialize the selectionSharer if there are non-handled elements present on the page
  • Upon initialization - find and remove the old selection sharer popup elements to avoid duplicate ID issues
  • Update selection-sharer.js with the new proposed changes https://github.com/xdamman/selection-sharer/pull/79 once it gets merged into master

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡²πŸ‡©Moldova nyph1337

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

Comments & Activities

Not all content is available!

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

Production build 0.69.0 2024