Skip to content

Feature / add link target support - #49

Merged
mpertici-beapi merged 3 commits into
developfrom
feature/link-target
Oct 2, 2026
Merged

mpertici-beapi merged 3 commits into
developfrom
feature/link-target

Conversation

@mpertici-beapi

@mpertici-beapi mpertici-beapi commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
Capture d’écran 2026-09-30 à 17 34 37 Capture d’écran 2026-09-30 à 17 30 44

Summary

  • Add a targetBlank block attribute (default false) and an "Open in a new tab" toggle in the link URL popover.
  • Render target="_blank" with rel="noopener noreferrer" on the front end when enabled.
  • Improve link toolbar UX: separate Edit / Remove actions when a link is set; reset targetBlank on remove.
  • Cover targetBlank behavior with PHPUnit cases in BlockRendererTest.

Test plan

  • Add a link on an icon block → confirm the popover shows the URL field and the "Open in a new tab" toggle
  • Enable the toggle → save → front end has target="_blank" and rel="noopener noreferrer"
  • Disable the toggle (or leave it off) → front end has neither target nor rel
  • With a link set, toolbar shows Edit link and Remove link; removing clears URL and targetBlank
  • Without a URL, no <a> is rendered even if targetBlank is true
  • Run composer test / PHPUnit and confirm the new BlockRendererTest cases pass

Note

Low Risk
Scoped to icon link rendering and editor UX; uses standard rel="noopener noreferrer" for external targets with existing URL escaping unchanged.

Overview
Adds optional open in a new tab for icon block links via a new targetBlank attribute (default false).

Editors get an Open in a new tab toggle in the link URL popover; when enabled, front-end markup includes target="_blank" and rel="noopener noreferrer". Link toolbar behavior changes when a URL is set: separate Edit link and Remove link actions, and removing a link clears both url and targetBlank. The popover layout is restyled so the URL row and toggle stack cleanly.

PHPUnit coverage asserts when target/rel appear or stay absent, including the case where targetBlank is true without a URL (no anchor rendered).

Reviewed by Cursor Bugbot for commit 5daa80b. Bugbot is set up for automated code reviews on this repo. Configure here.

- Introduced a new boolean attribute `targetBlank` to control link opening behavior.
- Updated the Edit component to manage the new `targetBlank` attribute.
- Enhanced the link URL popover with a toggle for opening links in a new tab.
- Implemented tests to verify that the `targetBlank` attribute correctly adds `target` and `rel` attributes to links.
- Added tests to ensure links without `targetBlank` do not include these attributes and that no link is produced when no URL is provided.
@mpertici-beapi
mpertici-beapi merged commit c6fb111 into develop Oct 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants