Problem/Motivation

Drupal core 11.4.10 strips hx-* and on* attributes from menu link content, so a Copy link control cannot carry its HTMX handler in the menu link itself. Vartheme BS5 Rightup solved this in the theme (#3631079). Vartheme BS5 has the same nav-menu component and Social media menu template, so it should offer the same.

Proposed resolution

  • 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 a menu link with the copy-link class, and attaches core/drupal.htmx only then. The message is translatable.
  • The nav-menu SDC gains an optional per-item link_attributes, merged into the link.
  • README: hx-on uses eval, so a strict Content Security Policy needs 'unsafe-eval' in script-src.

Nothing changes on a site until a Social media menu link has the copy-link class. Varbase Starter adds such a link in a separate issue.

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ➖ Developer Documentation support
  • ➖ User Guide Documentation support
  • ➖ UX/UI designer responsibilities
  • ❌ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ❌ Update Release Notes
  • ❌ Release

User interface changes

  • None until a menu link has the copy-link class.

API changes

  • Optional link_attributes per item in the nav-menu component.

Data model changes

  • N/A

Release notes snippet

  • A Social media menu link with the copy-link class copies the page address through core's HTMX.

AI-Generated: Yes. Drafted with Claude Code and reviewed before posting.

Command icon 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

rajab natshah created an issue. See original summary.

  • rajab natshah committed b5d6e903 on 5.0.x
    fix: #3631091 Add the HTMX copy handler to the Copy link in the social...
rajab natshah’s picture

Assigned: rajab natshah » Unassigned
Status: Needs review » Fixed
Issue tags: +vartheme_bs5-5.0.7

✅ Released vartheme_bs5-5.0.7

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.