ember-cli-document-title icon indicating copy to clipboard operation
ember-cli-document-title copied to clipboard

Fastboot initial title render

Open kellyselden opened this issue 9 years ago • 7 comments
trafficstars

A repost of #43. The title in the html payload is the initial state and not the final state.

kellyselden avatar Aug 16 '16 16:08 kellyselden

Is it known what work is required to get this working? Currently I think this issue is preventing the add-on from working correctly when used with ember-cli-staticboot with the includeClientScripts option disabled.

mike183 avatar Feb 26 '17 21:02 mike183

Is it known what work is required to get this working? Currently I think this issue is preventing the add-on from working correctly when used with ember-cli-staticboot with the includeClientScripts option disabled.

I don't think so. If you'd like to investigate, then please feel free to do so and share any findings here ❤️

kimroen avatar Mar 26 '17 15:03 kimroen

I don't feel quite sure enough about how best to fix this but I believe I've identified the problem.

In document-title.js, collectTitleTokens ultimately calls setTitle when it reaches a route with title set. However, it calls the router's setTitle, which is set when Router is reopened lower down in that module, not the route's setTitle. I added

  if(self.setTitle && typeof self.setTitle === 'function') {
    self.setTitle(finalTitle);
  }

right before the call to self.router.setTitle and it solved the problem, though perhaps there's some better option? Please advise and I'll be happy to submit a pull request.

mminkoff avatar Nov 20 '17 21:11 mminkoff

@mminkoff I tried implementing what you did on my own fork but it did not appear to make a difference. Does this look correct to you?

https://github.com/Ravenstine/ember-cli-document-title/commit/7d5160b488d4e7886730acf19cb77a5f22c67a2f

I don't want to go down the more primitive root of using ember-cli-head.

Ravenstine avatar Nov 23 '17 01:11 Ravenstine

That's correct @Ravenstine but yes it does depend on also using ember-cli-head (and adding setTitle to your route which then sets the title on the headData service.

If you don't use ember-cli-head then perhaps you'd have to use the method they use to affect what's in the head - the -in-element helper/component, which seems to be private/undocumented. See here: https://github.com/ronco/ember-cli-head/blob/master/addon/templates/components/head-layout.hbs

mminkoff avatar Nov 24 '17 15:11 mminkoff

@mminkoff Confirmed to work when using ember-cli-head. You have no idea how much time you've saved me.

Ravenstine avatar Dec 05 '17 20:12 Ravenstine

@Ravenstine So glad to hear it!! You have no idea how much time it took me to figure it out. :-)

mminkoff avatar Dec 06 '17 15:12 mminkoff