Redactor: Advanced Redactor settings seem to trigger "Leave Site?" warnings

Created on 31 Aug 2019  ·  15Comments  ·  Source: craftcms/redactor

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

Most helpful comment

We just released Redactor 2.4.0 with a fix for this!

All 15 comments

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

We just released Redactor 2.4.0 with a fix for this!

@brandonkelly I'm still experiencing this issue.

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

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

Can someone who is still experiencing this issue please send the following things to [email protected]?

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

@brandonkelly Sent

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.

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

@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.

@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.

@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.

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

@brandonkelly Updating to that version worked. Thanks!

Thanks for fixing this @brandonkelly!

Was this page helpful?
0 / 5 - 0 ratings