# Small action CustomComponent argument issue

**URL:** https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606
**Category:** Development
**Created:** [September 22, 2025, 11:01pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606 "2025-09-22T23:01:47Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [September 22, 2025, 11:01pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606/1 "2025-09-22T23:01:47Z")

</div>

I’m trying to optionally replace a post small action description with a CustomComponent.

However, the post is not correctly passed to the value transformer.

[Core code](https://github.com/discourse/discourse/blob/5d116eb709ef46eea38f358f89def236a4c62bc7/app/assets/javascripts/discourse/app/components/post/small-action.gjs#L59-L65)

```js
  @cached
  get CustomComponent() {
    return applyValueTransformer("post-small-action-custom-component", null, {
      actionCode: this.code,
      post: this.post,
    });
  }

```

My debugging code

```js
  api.registerValueTransformer(
    "post-small-action-custom-component",
    (arg) => {
      console.log(arg);
    }
  );

```

Output:

`context: Object { actionCode: "bid", post: undefined }`  
​​  
The [test](https://github.com/communiteq/discourse/blame/ef29250d781d642d365e8fe2593dff796516eb25/app/assets/javascripts/discourse/tests/integration/components/post/small-action-test.gjs#L70-L77) does not check the parameters, so this goes unnoticed.

I guess the post parameter should be `this.args.post` and not `this.post`.

I’ve been trying a workaround by unconditionally adding the component and having it check itself what to do but unfortunately it seems like the arguments are not being passed correctly either so both the workaround and a normal implementation fail here as well:

```js
              <this.CustomComponent
                @code={{this.code}}
                @post={{this.post}}
                @createdAt={{this.createdAt}}
                @path={{this.path}}
                @username={{this.username}}
              />

```

There are getters in `PostSmallAction` for `code`, `createdAt` and `path`, but (again) `this.post` does not exist and `username()` seems to have a bug as well (there is no `action_code_who` in `this.args.post` ?) , so those attributes stay empty.

I can’t find an existing “real world” implementation. Am I really the first one to use this ? 🤔

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [September 23, 2025, 12:14pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606/2 "2025-09-23T12:14:49Z")

</div>

I have made a PR that fixes this issue [FIX: correct argument passing for small action post value transformer and custom component by communiteq · Pull Request #34915 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/34915)

@david @saquetim could you have a look please 🥺

---

<div class="post-metadata">

### Author: ![saquetim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saquetim/32/116400_2.png) [@saquetim](https://meta.discourse.org/u/saquetim)
#### Post date: [September 23, 2025, 8:21pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606/3 "2025-09-23T20:21:35Z")

</div>

Thank you for noticing this issue.

> [@RGJ](#):
>
> I guess the post parameter should be `this.args.post` and not `this.post`.

You’re correct; the post parameter should be `this.args.post` instead of `this.post`.

> [@RGJ](#):
>
> There are getters in `PostSmallAction` for `code`, `createdAt` and `path`, but (again) `this.post` does not exist and `username()` seems to have a bug as well (there is no `action_code_who` in `this.args.post` ?) , so those attributes stay empty.

`username` is a bit misleading here. `action_code_who` is indeed correct but is used by some plugins like the `assign` plugin, so it’s not always present in the `post` object. To get the user who created the small action, you can use `@post.username`

I wasn’t sure if I could push changes to your PR, so I opened the one below to address these issues:

- fix the post argument passed both to the transformer and the custom component
- rename the `username` argument to `who` minimizing the confusion around this argument
- add tests to verify the arguments are passed correctly

[https://github.com/discourse/discourse/pull/34928](https://github.com/discourse/discourse/pull/34928)

---

<div class="post-metadata">

### Author: ![saquetim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saquetim/32/116400_2.png) [@saquetim](https://meta.discourse.org/u/saquetim)
#### Post date: [September 23, 2025, 8:24pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606/4 "2025-09-23T20:24:25Z")

</div>

> [@RGJ](#):
>
> I can’t find an existing “real world” implementation. Am I really the first one to use this ? 🤔

I think you are. 😃

AFAIK, the old API wasn’t used in any of the customizations we track in the `all-the-*` repos. I only added this one to provide an alternative in case a self-hoster was using it.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [September 23, 2025, 9:59pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606/5 "2025-09-23T21:59:40Z")

</div>

> [@saquetim](#):
>
> I opened the one below to address these issues

🚀 great!

> [@saquetim](#):
>
> I only added this one to provide an alternative in case a self-hoster was using it.

Well, thank you for being proactive 🙂  
I think discourse-encrypt used-to-use it, and three (!) private plugins that we’re maintaining.

> [@saquetim](#):
>
> `username` is a bit misleading here. `action_code_who` is indeed correct but is used by some plugins like the `assign` plugin, so it’s not always present in the `post` object. To get the user who created the small action, you can use `@post.username`

Thank you for explaining, I didn’t understand how this worked, and I do now.

Last favor to ask: could your fix be backported to stable as well?

---

<div class="post-metadata">

### Author: ![saquetim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saquetim/32/116400_2.png) [@saquetim](https://meta.discourse.org/u/saquetim)
#### Post date: [September 24, 2025, 8:56pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606/6 "2025-09-24T20:56:34Z")

</div>

The fix was [backported](https://github.com/discourse/discourse/pull/34964) to stable.

---

<div class="post-metadata">

### Author: ![saquetim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saquetim/32/116400_2.png) [@saquetim](https://meta.discourse.org/u/saquetim)
#### Post date: [September 25, 2025, 8:57pm UTC](https://meta.discourse.org/t/small-action-customcomponent-argument-issue/383606/7 "2025-09-25T20:57:21Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
