# 📄 Copy Post Component

**URL:** https://meta.discourse.org/t/copy-post-component/218883
**Category:** Theme component
**Tags:** official, copy-post
**Created:** [February 20, 2022, 3:51pm UTC](https://meta.discourse.org/t/copy-post-component/218883 "2022-02-20T15:51:40Z")
**Posts on this page:** 11
**Page:** 2

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [January 15, 2025, 3:40am UTC](https://meta.discourse.org/t/copy-post-component/218883/23 "2025-01-15T03:40:13Z")

</div>

Thanks for identifying that @Moin. I’ve pushed a fix:  
[https://github.com/discourse/discourse-copy-post/pull/5](https://github.com/discourse/discourse-copy-post/pull/5)

---

<div class="post-metadata">

### Author: ![Shauny](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shauny/32/362012_2.png) [@Shauny](https://meta.discourse.org/u/Shauny)
#### Post date: [February 17, 2025, 11:37pm UTC](https://meta.discourse.org/t/copy-post-component/218883/24 "2025-02-17T23:37:33Z")

</div>

I just get this error message whenever I click the copy button:

 ![The image shows a pop-up error message stating "Sorry, an error has occurred" with an "OK" button. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/e/5/e/e5e00c756fd2e94ea9c99f8bde807a85ae2b3c3a.jpeg)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [February 18, 2025, 12:00am UTC](https://meta.discourse.org/t/copy-post-component/218883/25 "2025-02-18T00:00:54Z")

</div>

Do you see any error in the browser’s console?

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [February 18, 2025, 8:32am UTC](https://meta.discourse.org/t/copy-post-component/218883/26 "2025-02-18T08:32:23Z")

</div>

I mentioned this issue on the other topic.

> [@Full quote button in editor missing](https://meta.discourse.org/t/full-quote-button-in-editor-missing/350719/25):
>
> I think the issue is that on iOS the copy only works if it comes from user interaction… It fails when it try to copy the quote. I will look for a solution if there are. confused There is the same issue in [page_facing_up Copy Post Component](https://meta.discourse.org/t/copy-post-component/218883).

> [@Full quote button in editor missing](https://meta.discourse.org/t/full-quote-button-in-editor-missing/350719/27):
>
> I tried a lots of way to fix this on iOS but it always fails on copy to clipboard because that wasn’t a real user interaction. So I’ve separated the actions and switches buttons between a prepare quote (which is fetching the quote) and copy quote (which is copy the quote to clipboard). This works fine. I also added a tooltip when the copy button appears.

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [March 17, 2025, 8:22pm UTC](https://meta.discourse.org/t/copy-post-component/218883/27 "2025-03-17T20:22:23Z")

</div>

I noticed an error on a site using the component as anonymous:

 ![The image shows a JavaScript error message indicating that a property cannot be read from a null object in a code snippet containing various object and array methods such as , , , , , , , and . (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/0/b/4/0b43d051d7c6c7693da14523c13f59d9583f2156.png)

I made a PR to fix it:

[https://github.com/discourse/discourse-copy-post/pull/14](https://github.com/discourse/discourse-copy-post/pull/14)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [March 24, 2025, 7:56pm UTC](https://meta.discourse.org/t/copy-post-component/218883/28 "2025-03-24T19:56:35Z")

</div>

The PR is now merged; thanks, Keegan!

---

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [June 30, 2025, 8:31am UTC](https://meta.discourse.org/t/copy-post-component/218883/29 "2025-06-30T08:31:24Z")

</div>

have users’ of this component been getting this error more recently

---

<div class="post-metadata">

### Author: ![Johnny\_McIvor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johnny_mcivor/32/218747_2.png) [@Johnny\_McIvor](https://meta.discourse.org/u/Johnny_McIvor)
#### Post date: [February 6, 2026, 3:49pm UTC](https://meta.discourse.org/t/copy-post-component/218883/30 "2026-02-06T15:49:45Z")

</div>

Just installed it, here’s an idea:

Click the copy button on multiple posts to “build up” your clipboard. That way you can quickly copy an entire section of a thread selectively.

Let’s say that there are five posts:

Post A  
Post B  
Post C  
Post D  
Post E

You copy D, then B, then E. What’s in your clipboard is actually:

B  
D  
E

So the clipboard is arranged based on their chronology in the conversation, not the order in which you copy them.

---

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [July 9, 2026, 7:50pm UTC](https://meta.discourse.org/t/copy-post-component/218883/31 "2026-07-09T19:50:55Z")

</div>

![IMG_1339](https://global.discourse-cdn.com/meta/original/4X/d/b/7/db75d6d6149d57700d857a4b701800d2dc44d6c3.png)

i had an error on this, and because it’s a client-side JS error, i can’t find it in `/logs`. My Discourse version is [2026.7.0-latest +188](https://github.com/discourse/discourse/commits/7b025265d254f731ba1036e550b7475b3d1c74b4)

---

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [September 16, 2026, 1:27pm UTC](https://meta.discourse.org/t/copy-post-component/218883/32 "2026-09-16T13:27:08Z")

</div>

I investigated this further against the exact Discourse revision from when I originally saw the problem, and against current `main`.

On a reconstructed historical July setup, I was able to reproduce a clipboard-related failure: Copy Post could show the success/check indication while the clipboard contents were not actually replaced. I cannot confirm that this was the same underlying error as the theme/component error shown in my original July screenshot.

However, the same Copy Post implementation now works on my current production instance, including in an iOS Safari PWA.

I compared the relevant code between the July Discourse revision and current `main`. The Copy Post clipboard implementation itself has not changed, and I could not find a relevant change in:

- `clipboardCopy` / `clipboardCopyAsync`
- `DButton` action dispatch, including the iOS path
- the legacy `DButton` shim
- the post-menu transformer path
- the GET path in `discourse/lib/ajax`

I also wrote an experimental system spec which pauses the raw-post request and checks whether `navigator.clipboard.write()` has started before the request completes. That test passes if Copy Post is changed to use `clipboardCopyAsync`, and fails against the current implementation.

However, current Copy Post works in the browsers/devices I have tested, including iOS Safari PWA, so that test appears to enforce a stronger implementation constraint rather than demonstrate a current user-facing regression.

For that reason I am not currently proposing that test or the `clipboardCopyAsync` change as a fix. The historical failure may have depended on browser/WebKit behaviour rather than a change in the Copy Post component itself.

---

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [September 16, 2026, 2:29pm UTC](https://meta.discourse.org/t/copy-post-component/218883/33 "2026-09-16T14:29:44Z")

</div>

Following up on this, I’ve opened a small PR which changes the success/check indication so it is only shown after the clipboard write has completed successfully, with a regression system spec:

> <https://github.com/discourse/discourse-copy-post/pull/39>
>
> This changes the Copy Post success indicator so the check icon is only shown aft…er the clipboard write has completed successfully.
> 
> Previously, the component set the check icon before awaiting \`clipboardCopy()\`, which meant it could show success while the clipboard operation was still pending.
> 
> The previous widget implementation showed copied/success feedback only after the clipboard promise resolved, and Discourse's core copy button follows the same pattern.
> 
> This PR:
> 
> \- moves \`this.icon = "check"\` to after \`await clipboardCopy(postContents)\`
> \- adds a system spec which holds the clipboard write pending and verifies that the success icon is not shown until the write resolves
> 
> Testing:
> 
> \- focused Copy Post spec: 6 examples, 0 failures
> \- full component suite: 26 examples, 0 failures
> \- \`pnpm lint\`: all lint, formatting, template, CSS and type checks passed
> \- manually tested on a July 2026 Discourse revision; normal clipboard feedback remained effectively instantaneous, and artificially delaying the clipboard promise did not block or lag other Discourse interactions

The GitHub Actions workflow is currently awaiting maintainer approval before the CI jobs can run.

[Previous page](https://meta.discourse.org/t/copy-post-component/218883.md?page=1)
