Fix Text Animation destroying links added inside animated text - #285
Merged
Conversation
Every character-splitting animation handler rebuilt its element from el.textContent, which silently discards any inline HTML — most importantly, a link the author added to part of the text: the <a> itself was destroyed on the very first animation play, leaving only its unlinked text. Skip the destructive per-character rebuild entirely for any animated element whose content contains inline formatting (a, strong, b, em, i, mark, code, abbr, sub, sup, span, kbd). The text is left exactly as authored — link intact and clickable — at the cost of that specific text not playing the character animation, which is a much safer failure than silently destroying the author's link.
Verifies init() skips the character-splitting handler for any element whose direct children include a link or other inline formatting tag, and hands unformatted content through unchanged.
Registers test:text-animation in package.json and adds it to the JavaScript tests CI job alongside the existing cookie-notice test.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Contributor
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
davidperezgar
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a real bug reported by a user: adding a link to part of the text inside a block "breaks" — the link silently disappears.
Root cause
Every character-splitting animation handler in
assets/text-animation/animations/*.js(fade-in, wave, typewriter, etc. — applicable to any paragraph/heading with the FrontBlocks "Text Animation" panel enabled, or the dedicated Text Animation block) rebuilds its element fromel.textContenton first play, discarding all inline HTML. If the author had wrapped part of the text in a link, the<a>itself was destroyed — only its unlinked text survived.Verified this was unrelated to PR #274 (that PR isn't even merged, and only touches server-side attribute registration for the entrance-animation feature — no RichText/link code at all).
Fix
assets/text-animation/frontblocks-text-animation-frontend.js'sinit()now skips the destructive per-character rebuild entirely for any animated element whose direct children include an inline-formatting tag (a,strong,b,em,i,mark,code,abbr,sub,sup,span,kbd). That content is left exactly as authored — link intact and clickable — at the cost of that specific text not playing the character animation. A missing animation is a far safer failure than silently destroying the author's link.Test plan
tests/js/text-animation-inline-formatting.test.js,npm run test:text-animation) covering: content with no formatting is still animated; content with a link, or any other inline tag, is skipped.test:cookie-noticejob.<a href="...">survives, hascursor: pointer, and a real click navigates to the target URL.composer lint(phpcs) clean.