prismicio / prismic-toolbar

An embeddable UI for Prismic content and previews directly on your website.
12 stars 19 forks source link

Preview cookie not deleting on toolbar close #16

Closed tremby closed 6 years ago

tremby commented 6 years ago

The cookie is not being properly deleted when I click to close the toolbar. I'm getting this both in my development environment (which has a non-standard port number and a short domain), and in my staging environment (standard port, regular-looking domain).

I have the same behaviour for live and draft previews.

Firefox 57.

gsteel commented 6 years ago

Experiencing the same issue on Safari 11/Mac and on Chrome 63/Mac

tremby commented 6 years ago

I just dug into it a bit.

I was setting the preview cookie without a domain parameter. The toolbar code never attempts to delete the cookie with no domain parameter. But to delete a cookie you need the domain parameter to match exactly.

So my workaround is to set the preview cookie with a domain -- now the toolbar will delete it. Specifically, I set domain to be the value of location.hostname.

However, this should be fixed in prismic-toolbar; it should attempt the deletion without the domain parameter as well as with.

gsteel commented 6 years ago

Thanks for sharing that @tremby, explicitly setting the domain worked for me too!

srenault commented 6 years ago

Ok got it. I'm going to fix this.

srenault commented 6 years ago

Ok it's fixed in the prismic.js script: static.cdn.prismic.io/prismic.min.js. Just to let you know that the prismic-toolbar has been deprecated and won't get anymore updates. The official way to go is to use static.cdn.prismic.io/prismic.min.js.

tremby commented 6 years ago

Is the source available for the one on your CDN there?

As you can see from my pull requests here, there are various features I want. I'll contribute or fork. To have neither option would be quite a shame.

srenault commented 6 years ago

No worries, We're going to keep the work here. BTW, the PR that fixes the close session is here https://github.com/prismicio/prismic-toolbar/pull/17.

tremby commented 6 years ago

So this is not deprecated after all? I'm confused.

srenault commented 6 years ago

The toolbar itself isn't deprecated. What is deprecated is the npm package. Sorry I wasn't very clear.

tremby commented 6 years ago

I'm still confused.

You said "We're going to keep the work here", and showed me the patch which fixes this issue, and it's here in this repository, which the NPM package is built from. But then you say the NPM package is deprecated. Are you saying that the source for the toolbar you publish on your CDN will stay up to date here in this repository, you're just not going to publish an NPM package of it any more?

srenault commented 6 years ago

Yes that's it. We're going to unpublish prismic-toolbar npm package.

tremby commented 6 years ago

I take it the reason is to encourage people to use the version on your CDN, so people aren't complaining about broken things you've already fixed, and possibly so you can get stats on usage.

Please forgive me repeating myself, but just so we're totally 100% clear, is this repository going to remain the source of the build you distribute on your CDN? (I.e. will this repository stay up to date?)

srenault commented 6 years ago

The answer is Yes. I confirm that repository will always be used for prismic.js script we distribute over our CDN.