Remove Parent Category from Inline Category Mentions

:double_exclamation_mark: I realize this is very likely covered in these changes, but not sure if the inline updates are tied to hover cards being enabled.

Short description

Clean up your inline category mentions by removing the parent category. Includes an option to exclude specific categories (and keep the parent category).

Effect is applied in:

  • Category mentions in posts
  • The live preview pane in the composer
  • The # mention autocomplete dropdown in the composer

Screenshots

Before

After

With category excluded

3 Likes

Thanks for sharing. I think it will be fixed on Discourse, in the meantime it’s a functional workaround.

Something important to mention is that the component uses MutationObserver and it is a practice that is suggested to avoid.

1 Like

Thanks, I’ll look into an alternative approach!

1 Like

Thanks again for the heads-up on the observer. I was unaware it’s not recommended.

I removed it everywhere except the composer (the live preview and the # dropdown), since no hook is available for those. And instead of watching the whole page, each one now just watches its own little area.

If a Discourse update ever changes things and it stops working, the composer would just show the full “Parent > Child” name like it normally does. :slight_smile:

2 Likes

Oh, thank you for taking it into consideration! Being honest I was aware about it when starting to vibe code into Discourse and then Sam confirmed it.

Fortunately there are almost always different approaches to take, so plugins and theme components are aligned with the suggested practices and can be easily maintained.

I will use your TC because I really want this new feature working as expected :ok_hand:

2 Likes