fix: #3631079 Add the HTMX copy handler to the Copy link in the social media menu template

Issue: https://www.drupal.org/i/3631079

  • The Copy link uses core's HTMX (core/drupal.htmx, htmx 2.0.x in core 11.4.10; core ships no HTMX 4).
  • menu--social-media-menu.html.twig adds hx-on:click (copy the page address, add is-copied, announce "Link copied") and hx-on:keydown (Space) to the item whose link has the copy-link class. The message is translatable with |t.
  • The nav-menu SDC gains an optional link_attributes per item, merged into the link through Twig link(). It is generic and reusable, and nav-menu is noUi, so no Canvas component version changes.
  • Why the template: core 11.4.10's AttributeXss strips hx-* and on* from menu link content, as htmx's own security advice says to do for user content. So hx-on lives only in theme markup, keyed on a class.
  • The custom js/copy-link.js and its library from the first commit are removed.
  • README: hx-on uses eval, so a site with a strict Content Security Policy needs 'unsafe-eval' in script-src.

Checked headless at 1440 and 390 on core 11.4.10. Click, Enter and Space each copy the URL and stay on the page, with no console errors. 01-06-front-end-pages.feature passes: 28 scenarios.

Merge order: merge this MR first and let the 1.0.x-dev theme repackage. Then merge rightup!85 (merged), whose footer test checks this handler, then rebase rightup !84. For The Rightup 1.0.6: release this theme first, then raise !83's theme pin to ~1.0.6.

AI-Generated: Yes

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release
Edited by Rajab Natshah

Merge request reports

Loading
Loading