Js.composer.reply_placeholder applies to New Topics as well as Replies

Issue Description

The js.compser.reply_placeholder text appears to be coupled to the text in the composer when a topic is created, despite being reply specific.

How to reproduce?

This can be seen by comparing a modified version of placeholder text to the composer.

Some fixes that come to mind

One fix might be to change the name of the placeholder, however we would love to have the option to modify the placeholders of both replies and creates separately.

Why would create and reply placeholders be useful?

As shown below, we’ve started using the following placeholder text for new topics. However, this guidance makes no sense in the context of a reply.

The image displays a computer screen with a word processor open, showing a blank document with a title bar at the top.  (Captioned by AI)

If the fix for this resulted in a placeholder for both replies and creating, we would be able to provide improved JIT guidance for all users(which would be amazing for support communities like ours).

2 Likes

Maybe the code in this topic helps you

2 Likes

:heart: That’s a great find. Gave it quick try and seems to very nicely separate the reply and create placeholders. Would love to see this change made in core, but very happy to use the changes given by Joe. Thanks for linking this @Moin

4 Likes

Just as a followup, the code snippet posted by Joe didn’t work as expected with our new topic button: when a user creates a new topic while they were reading a topic, they would get the reply text.

Below is an alternative appraoch which:

  • Presents a placeholder for new topics whether they are started in the Categories page or from within a topic
  • Presents a different placeholder for replies
<script type="text/discourse-plugin" version="0.8">
// Custom placeholders
const placeHolderForReplies = `When helping someone else:

1. Describe what you think the problem is
2. Tell them what you think they should do
3. Show them how to do it (code snippets, images, etc)
4. Include links and references `;

const placeHolderForNewTopics = `Type here.

1. Tell us what you're trying to do.
2. Tell us what you already tried.
3. Post error logs as code snippets.`;

// Import required modules
const discourseComputed = require("discourse-common/utils/decorators").default;
const currentLocale = I18n.currentLocale();
I18n.translations[currentLocale].js.composer.custom_reply_placeholder = placeHolderForReplies;
I18n.translations[currentLocale].js.composer.custom_topic_placeholder = placeHolderForNewTopics;

api.modifyClass("component:composer-editor", {
  @discourseComputed("composer.replyingToTopic", "composer.creatingTopic")
  replyPlaceholder(replyingToTopic, creatingTopic) {
    // Determine if the composer is for replying or creating a new topic
    if (creatingTopic) {
      return "composer.custom_topic_placeholder";  // New topic placeholder
    } else if (replyingToTopic) {
      return "composer.custom_reply_placeholder";  // Reply placeholder
    }
    return this._super(...arguments);  // Fallback to default behavior
  }
});
</script>

2 Likes

There is also

3 Likes