Slow loading times for a topic's title

AI-generated summary

In the UX category, watchmanmonitor reported a UI inconsistency where clicking a link to a new topic updates the browser URL and window title immediately, but the Discourse header retains the old topic title until the page fully loads. sam agreed this is a poor user experience, suggesting the header should re-render instantly upon click. codinghorror supported the change if it were simple. However, eviltrout explained the complexity: suggested topics use raw Handlebars, meaning the application knows the new URL but lacks the data object required to update the title immediately without a full load. fefrei proposed blanking the title during the transition as a consistent alternative to showing the old one, a suggestion codinghorror endorsed. After sam queried if the specific component could be extended, eviltrout noted that while simple in appearance, the task involved significant edge cases regarding title visibility and load states. Ultimately, eviltrout implemented a fix to make the application smarter about displaying titles during navigation, referencing commits 6f23094 and d161422.

Continuing the discussion from Can I add a loading image like slack has while the app is loading?:

I’ve seen this behavior a number of times recently, it’s kind of ironic that the topic I clicked on which ended up prompting me to stop & start a topic is one about slow load times.

The issue at hand is that when I’m on a Topic A and client on a link at the bottom to Topic B, both the URL in my browser (chrome on mac) and the window’s title change quickly, but the topic title doesn’t change until after more of the page loads.

I’ve seen this here on meta more than anywhere else. Outside of making pages load faster, I wonder if the updating of the title itself should get prioritized?

6 лайков

I really like this observation, we can certainly re-render the header right away on click.

@eviltrout maybe have a look at it.

Repro is visiting a topic, clicking on a suggested topic. The expectation is that the header would re-render right away with the new title / category and so on. Instead you see the spinner and old title.

5 лайков

Sure I support this if it is easy, seems like a nice change.

This is more complicated than you might think.

The suggested topics list is done with raw handlebars, so each link is just a regular link that is run through our router. We know the URL to update right away because it comes from the link, but we don’t have the data object to use for the title / category.

(If it was a regular handlebars template we’d have an easy reference to the object for updating instantly like that.)

7 лайков

In that case, blanking out the title might actually look better than keeping the old title?

Keeping the old title is weird in some way, the title simply being removed together with the content of the page seems pretty consistent to me :slight_smile:

6 лайков

Sure let’s go with that @eviltrout, removal, since that has to be easy, I hope?

3 лайка

I think we have a component per row and it has the backing topic, it handles the click. Can it be extended to sort this out @eviltrout? (components/topic-list-item.js.es6)?

1 лайк

Isn’t it always the way that simple appearing things are always more complicated? There were a lot of edge cases due to the topic title not always being visible, and it depending on a “loaded” state.

It took a while, but I think I managed to make our application a lot smarter about showing topic titles when navigating to them from topic lists.

https://github.com/discourse/discourse/commit/6f230945c2fe05036ee9d4d4e129bdb6105f64b4

and

https://github.com/discourse/discourse/commit/d1614220022311501e926632343f695e865d6ef2

13 лайков