Repository navigation
File block: Remove anchor tag when copy pasting to file name - #56508
Conversation
|
Size Change: +345 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
| downloadButtonText: removeAnchorTag( | ||
| _x( 'Download', 'button label' ) | ||
| ), |
There was a problem hiding this comment.
Although this would not be necessary in practice, it allows for the possibility that the translated text has anchors.
There was a problem hiding this comment.
This translated text shouldn't have HTML in it, and React shouldn't render it anyway. So I agree this is unnecessary.
We can't strip every possible translation.
|
Flaky tests detected in 0bf95cd. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6982994376
|
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Nice fix @t-hamano 👍
✅ Everything tests as advertised
✅ Anchor tags are correctly stripped out
✅ Block isn't broken and renders as expected on the frontend
Do you think it is worth extracting the removeAnchorTag into a helper function that can be shared across blocks?
LGTM 🚢
|
Thanks for the review, @aaronrobertshaw!
That makes sense. Updated 👍 |
* File block: Remove anchor tag when copy pasting to file name * Don't strip default button text * eEtract removeAnchorTag() function
Fixes #54820
Follow-up #29273
What?
This PR fixes an issue where if content containing an anchor is pasted into the filename of a file block, validation will fail and the block will become corrupted.
Why?
This block's file name and button are both anchor elements, so you cannot put an anchor element inside them. In #29273, this issue was fixed for the download button, but the same fix should be applied for the file name as well.
How?
I also added a process to remove anchors in the file name. At the same time, I changed the function name to something easier to understand, and changed the function to purely processing strings without executing
setAttributes()inside the function.Testing Instructions
Screenshots or screencast
132a90c04813d9e5778b77e5a201d2a7.mp4