-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: Ensure Copy button in sidebar copies whole permalink, *with* URL protocol #61876
Conversation
`usePostURLLabel` is meant to be used in labels and intentionally strips the protocol of a URL. As a result, the copy button in the `PostURL` component wrote something like "example.org/foobar" to the clipboard, instead of "https://example.org/foobar". As a fix, just grab the permalink directly.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +218 B (+0.01%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
Flaky tests detected in 03f0364. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9206152426
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you! I've left a small comment and it's good to 🚢
( select ) => select( editorStore ).getPermalink(), | ||
[] | ||
); | ||
const copyButtonRef = useCopyToClipboard( permalink, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also use safeDecodeURIComponent
for the copied permalink.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ntsekouras: Is it needed in practice? I had a quick look at getPermalink
, getPermalinkParts
and I don't see where we'd get encoded components from. Also:
In the above scenario I see http://localhost:8881/2024/05/ola-φίλε/
in my clipboard, as expected.
Finally, I also just refactored to use the existing useSelect
call in that component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.. yesterday I tested with some greek and accents and it produced a URL that needed it. Don't remember what I tried exactly though and couldn't reproduce today with random tests, that could be similar to the yesterday ones..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I should just add the decoder to be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Miguel!
…URL protocol (WordPress#61876) * PostURL: Copy whole permalink, *with* protocol `usePostURLLabel` is meant to be used in labels and intentionally strips the protocol of a URL. As a result, the copy button in the `PostURL` component wrote something like "example.org/foobar" to the clipboard, instead of "https://example.org/foobar". As a fix, just grab the permalink directly. * Docs: Fix grammar * Fold permalink selection into existing useSelect call * Filter through safeDecodeURIComponent -- you never know
…URL protocol (WordPress#61876) * PostURL: Copy whole permalink, *with* protocol `usePostURLLabel` is meant to be used in labels and intentionally strips the protocol of a URL. As a result, the copy button in the `PostURL` component wrote something like "example.org/foobar" to the clipboard, instead of "https://example.org/foobar". As a fix, just grab the permalink directly. * Docs: Fix grammar * Fold permalink selection into existing useSelect call * Filter through safeDecodeURIComponent -- you never know
usePostURLLabel
is meant to be used in labels and intentionally strips the protocol of a URL. As a result, the copy button in thePostURL
component wrote something like "example.org/foobar" to the clipboard, instead of "https://example.org/foobar".As a fix, just grab the permalink directly.