Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prismic's Toolbar isn't initialized when Nuxt's globalName has been modified #81

Closed
egstad opened this issue Jun 7, 2020 · 2 comments · Fixed by #84
Closed

Prismic's Toolbar isn't initialized when Nuxt's globalName has been modified #81

egstad opened this issue Jun 7, 2020 · 2 comments · Fixed by #84
Labels
bug Something isn't working

Comments

@egstad
Copy link

egstad commented Jun 7, 2020

[Outdated - see comment below]

I've noticed that the Prismic Toolbar has been missing over the last few releases. I've tried clearing cache, deleting cookies, deleting .nuxt files, updating my npm packages, but no dice. Anyone else run into this issue and solve it?

I get these warnings in the console, but don't see how map files would cause this error.
image

Versions I've tested on and
nuxt: 2.11.2 - 2.12.2
@nuxtjs/prismic: 1.1.0 - 1.2.1. Also tried this on the #get-preview-resolver branch

Here is my nuxt.config.js.

  prismic: {
    endpoint,
    linkResolver: '@/plugins/prismic/prismic-link-resolver.js',
    htmlSerializer: '@/plugins/prismic/prismic-html-serializer.js',
    preview: '/preview/'  
  },

Would appreciate any assistance here. Without the toolbar, I've lost the ability to view anything but Prismic's master branch and create shareable staging links.

Thank you!

@egstad
Copy link
Author

egstad commented Jun 7, 2020

I've found the issue...

This package doesn't hold nuxt's globalName into account. This is what is called in prismic.js.

  // Load prismic script after Nuxt app is mounted
  if (process.client) {
    window.onNuxtReady && window.onNuxtReady(() => {
      const script = document.createElement('script')

      script.src = '<%= options.script %>'
      document.body.appendChild(script)
    })
  }

My globalName is set to app, meaning that onNuxtReady becomes onAppReady. Upon changing the above to the following, the preview toolbar is back...

  // Load prismic script after Nuxt app is mounted
  if (process.client) {
    window.onAppReady && window.onAppReady(() => {
      const script = document.createElement('script')

      script.src = '<%= options.script %>'
      document.body.appendChild(script)
    })
  }

This update makes the toolbar operational. It's not perfect though - i'm receiving a polling iframe error every ~3 seconds.
image

@egstad egstad changed the title Prismic Toolbar is missing Prismic's Toolbar isn't initialized when Nuxt's globalName has been modified Jun 7, 2020
@tjkohli
Copy link

tjkohli commented Jul 6, 2020

We are having this issue as well. What's the solution without having to change our global name back?

@lihbr lihbr added available soon bug Something isn't working labels Jul 17, 2020
@lihbr lihbr mentioned this issue Jul 17, 2020
3 tasks
@lihbr lihbr closed this as completed in #84 Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants