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

Advanced Redactor settings seem to trigger "Leave Site?" warnings #161

Closed
jsunsawyer opened this issue Aug 30, 2019 · 16 comments
Closed

Advanced Redactor settings seem to trigger "Leave Site?" warnings #161

jsunsawyer opened this issue Aug 30, 2019 · 16 comments

Comments

@jsunsawyer
Copy link

I just updated a Craft site and all its plugins to the recent versions. As soon as I started testing the site, I experienced "Leave Site?" warning messages when navigating away from any entry that had a populated redactor field.

It seems that any redactor field that has any of the following settings checked (see image) and has at least 2 formatting types (blockquote and h2 for example) will cause this warning message to pop up.

Screen Shot 2019-08-30 at 3 31 29 PM

@nixondesigndev
Copy link

Also running into this issue. Occurs when the field has more than one tag e.g.

<p>Test</p>
<p>Test</p>

or

<p>Test <a href="">link</a></p>

Craft Pro 3.2.10
Redactor 2.3.3.2

@brandonkelly
Copy link
Member

We just released Redactor 2.4.0 with a fix for this!

@jsunsawyer
Copy link
Author

@brandonkelly I'm still experiencing this issue.

@nixondesigndev
Copy link

Can confirm we're also still seeing the issue, but the fix has alleviated the issue in some cases.

@jsunsawyer
Copy link
Author

@brandonkelly Any chance we could re-open this issue? I'm still regularly experiencing this in Craft 3.3.10 / Redactor 2.4.0

@brandonkelly
Copy link
Member

Can someone who is still experiencing this issue please send the following things to support@craftcms.com?

  • a database backup
  • your config/redactor/ folder
  • your composer.json and composer.lock files

@jsunsawyer
Copy link
Author

@brandonkelly Sent

@brandonkelly
Copy link
Member

Was able to reproduce when the field contained a void tag, where Redactor and HTML Purifier disagree on the syntax that should be used (<hr> vs <hr />). Also if there were any images, Redactor likes to add data-image attributes at random on initialization.

The self-closing tag syntax could have been prenormalized from PHP, but we can’t do anything to anticipate what those data-image attributes should be ahead of time. So I decided to just fix this from Craft’s end, by adding a little delay before storing the initial form values, giving Redactor a little more time to get its value normalized before it’s captured as the initial form value.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#602679ea534e23838ea03d3bb82552471ebc1d24 as 3.3.13",
  "...": "..."
}

Then run composer update.

@stenvdb
Copy link

stenvdb commented Oct 24, 2019

Hi @brandonkelly, can confirm this fixes it for Redactor on our end. But unfortunately we also get the popup on field layouts with the grid field enabled https://plugins.craftcms.com/grid

@jsunsawyer
Copy link
Author

@brandonkelly I'm still getting this error pretty regularly.

I tested a simple entry with a single Redactor field. I added a 2nd paragraph, then saved. Upon deleting the 2nd paragraph, a <br> tag was left (which seems like its own issue).

This is what the Redactor content looks like when viewing through the "html" option.
<p>Save $25 for every $500 you spend in store. Loyalty members also receive early access to exclusive offers, text message discounts, special product bundles, major event invitations, and new product announcements. Ask your Docent for more details.<br></p>

So it seems like the <br> tag is still regularly causing issues in this case.

@brandonkelly
Copy link
Member

@jsunsawyer And to be clear you definitely updated Craft to 602679ea534e23838ea03d3bb82552471ebc1d24 first per my last post? At that point it shouldn’t matter what Redactor does with its field value on initialization, as Craft won’t record its “initial” page value until after all other JS on load/doc-ready is finished executing.

@jsunsawyer
Copy link
Author

@brandonkelly Ah, sorry. I just updated to the released version of 3.3.13. I assumed that this fix was included. Let me check it out.

@brandonkelly
Copy link
Member

@stenvdb You’ll have to open an issue at https://github.com/wbrowar/craft-grid/issues about that.

@jsunsawyer
Copy link
Author

@brandonkelly Updating to that version worked. Thanks!

@mattandrews
Copy link

Thanks for fixing this @brandonkelly!

@LorindaH
Copy link

LorindaH commented Feb 9, 2024

I'm having this issue years later with version 3.0.4. Adding the text field doesn't make the "Leave Site" notice appear. If I add a link to the text (using the link button in the field's toolbar) then even if no edits are made the "Leave Site" notice appears when you leave the entry editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants