Topic Template Placeholder Text theme component

Very difficult to test on old versions. This was made to work on latest tests-passed. It is very possible it is simply not compatible with older Discourse instances.

Are you getting a javascript error in the console? That might be causing the incomplete render. This is not a styling Component :slight_smile:

Very occasionally Core does such a big change that the required override has to be altered in a way that doesn’t support the older codebase. That said my PR included a lot of very careful overrides that should be robust to changes in core. You can only do so much though.

Appreciate the reply @merefield

This error in the console does indeed seem like it would be related:

Yep, that’s a pretty basic incompatibility. Decorators are being imported from a new location now because the old import location has been deprecated. It’s likely that location doesn’t exist on your old install.

I suggest you wait for your Discourse to be updated to a more modern version.

Cool! No worries, thanks for the quick responses @merefield :smiley:

1 Like

@Ryan_NR - in the meantime you could try the original version which may not require these same dependencies?

https://github.com/naidihr/discourse-topic-template-placeholders_original

1 Like

I believe Theme branching works, so you could maintain 3 branches on the same Theme (tests-passed, beta & stable)

However, that will not catch everyone and it’s a lot of additional work to maintain and keep things working especially if the maintainer is a volunteer.

Thanks @merefield. I thought that branching might confuse so created a new repository - just to check if it removes the version dependencies for @Ryan_NR?

1 Like

Your solution is simpler in this instance. I was just speaking my mind strategically :slight_smile:

I’ll give that a try! Thanks @Rhidian :smiley:

1 Like

Got it… This works perfectly!

Thank you both so much! :smiley: :smiley:

You’re welcome. Glad to be able to help :blush:

I’ve updated the instructions in case anyone else has this same issue.

2 Likes

I just realized that this text shows up when you’re replying to a post, not just for creating a topic. Which, at least in my scenario does not work particularly well, is there any possibility for it to only show when creating a topic in the same way the topic template works now?

3 Likes

Well spotted. The original version behaves correctly - so it only shows on new topics - the same way the topic template does.

You can download the original here.

Original version repo: https://github.com/naidihr/discourse-topic-template-placeholders_original

It was a simple Jquery switch to move the template text to the placeholder IF it matches the template text.

@merefield are you able to look at this again?

Sure. So you want this to happen only on first post? Are there any circumstances where you might want it to happen on subsequent posts?

Thanks Robert. No just as described - in the same way the original works. It should only do the conversion to display it as placeholder text if the custom template text matches the text that is in the composer.

That was why I did the JQuery hack in the first place as I could only work out how to do that check once it had rendered?

Resolved and added a setting, default TRUE, that restricts it to first post.

This actually adds a feature, in that the Topic Template (or custom Placeholder text) can now apply to all posts if you so choose :slight_smile:

https://github.com/naidihr/discourse-topic-template-placeholders/pull/4

I’ve tested it reasonably thoroughly (dev and prod) but please feel free to check

4 Likes

Thanks Robert. I’ve merged that in to test it.

It fixes the issue described but has added a new issue. If you have a draft a reopen it - the draft text is now lost. Please can you check that?

The behaviour should be that it only makes the conversion if the text that is to be displayed in the composer matches the template text.

I cannot yet reproduce … can you give me exact STR including exact settings when you saw this? My draft reply and draft new Topic came back fine.

This happens if I go to a topic that has custom template. I start a draft. Then I leave the site. I come back to the site - click on my avatar logo top right and name - and click Drafts

image

I then click Resume on the draft that was saved.

image

The text doesn’t appear - instead I get the placeholder text.

Discourse 4.4.3

1 Like

Working with @merefield we think we have fixed this and another issue now.

@davidkingham - please can you confirm?