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

[4.x]: Autosave Drafts reloads all other languages of an entry, not just the language where the change was made #14814

Closed
proimage opened this issue Apr 15, 2024 · 8 comments

Comments

@proimage
Copy link

What happened?

Description

My client has a multi-lingual site (~12 languages), and the weekly article they post gets translated into almost all of those languages. Perhaps needless to say, their Content Editor doesn't speak/read all of those 12 languages. They just receive the original English, apply consistent semantic formatting, and post it.

Meanwhile, multiple translators work on translating the article into their own languages. When each translation is ready, it's sent (usually as a Word doc, so badly in need of semantic formatting) to the Content Editor.

The Content Editor then opens two side-by-side tabs of the article in the backend: one English, and the other in the language they're working on. Therein lies the problem with the Autosave Drafts feature, however, since when, say, a Spanish version of the entry is autosaved, the tab with the English version also gets refreshed.

So, is there a future-proof way going forward (I know autosaveDrafts is deprecated in Craft 4.x for some reason) to either disable autosaving of drafts, or perhaps better, to not refresh all language versions of an entry when a draft is made in some other language?

Steps to reproduce

  1. Create a section with multiple languages.
  2. Post content to the fields in the original language.
  3. In a new tab alongside the original language, make edits to the content in some other language.
  4. Watch the original language's tab get refreshed.

Expected behavior

Autosaving of a draft entry in one language would not cause the Edit Entry page of all other languages to reload.

Actual behavior

Autosaving of a draft entry in one language DOES cause the Edit Entry page of all other languages to reload.

Craft CMS version

4.8.8

PHP version

8.2.17

Operating system and version

Linux 4.19.286-203.ELK.el7.x86_64

Database type and version

MySQL 23

Image driver and version

Imagick 3.5.0 (ImageMagick 6.9.10-68)

Installed plugins and versions

  • Contact Form 3.1.0
  • Contact Form Honeypot 2.1.0
  • Control Panel CSS 2.6.0
  • Redactor 3.0.4
  • Redactor Custom Styles 4.0.3
  • Super Table 3.0.13
  • Twigpack 4.0.0
  • Wordsmith 4.4.0
@brandonkelly
Copy link
Member

This is working as intended. The other tab will get refreshed because something about its content may have just changed, e.g. any non-translatable fields, or things like the entry’s post date.

@proimage
Copy link
Author

Ok, that makes sense... so what about autosaveDrafts being deprecated? Is that replaced with something else, or is there just no way to prevent autosaving drafts going forward?

@brandonkelly
Copy link
Member

autosaveDrafts was added in Craft 3 as a temporary solution to make content editing more tolerable on installs where saving an entry took several seconds each time.

That hasn’t been the case nearly as much in Craft 4+, and we’re continuing to find ways to improve performance with each major release, and the plan is to remove it once long save times are fully resolved.

So it’s a performance hack; not meant to be an alternate workflow you might want to opt into.

@proimage
Copy link
Author

I've updated the site in question to Craft 4.x, and the auto-refreshing is more disruptive than expected. The content is long-form, so smallish WYSIWYG fields don't really cut it, which is why the content editor has the WYSIWYG fields in their full-screen modes. There are multiple language windows open in parallel, each with their WYSIWYG in full-screen mode. Whenever changes are registered in any of the open windows, they all refresh, which exits them out of full-screen and reloads their pages, losing the place in the long-form content being edited.

For now, what they're doing is pasting the English reference content into a temporary entry, and only editing one translation at a time. Obviously, this greatly slows down the editing process.

So this is a multi-tasking, content-editing related issue, made difficult by the Autosave Drafts feature.

Do you have any suggestions?

brandonkelly added a commit that referenced this issue May 21, 2024
brandonkelly added a commit to craftcms/redactor that referenced this issue May 21, 2024
@brandonkelly
Copy link
Member

Hey @proimage, couple updates:

  • I found and fixed a bug where the scroll positions weren’t being maintained properly on reload, when more than two tabs were open to the same entry’s edit page.
  • Craft 4.10 and 5.2 will allow plugins to partially1 disable auto page reloading, and Redactor2 will take advantage of that when in fullscreen mode, once Craft 4.10 and 5.2 are out.

You can update to Craft 4.10 / 5.2 and the Redactor change right now by setting the following constraints in composer.json, and then running composer update:

// Craft 4.10
"craftcms/cms": "4.10.x-dev as 4.10.0-alpha",
"craftcms/redactor": "3.x-dev as 3.1.0-alpha",

// Craft 5.2
"craftcms/cms": "5.2.x-dev as 5.2.0-alpha",
"craftcms/redactor": "4.x-dev as 4.1.0-alpha",

1 Other tabs will still reload when a provisional draft is first created in the active tab, or when a draft is deleted/applied, because it’s crucial that all tabs are working with the correct revision at those points.

2 I’m assuming that’s what you’re using, but the same logic could easily be applied to other rich text editors (besides CKEditor, which doesn’t have first party fullscreen mode).

@proimage
Copy link
Author

Thanks, @brandonkelly, that looks like those changes should address the core issue. :) As I understand it, Redactor scroll positions will be kept more consistent due to a bugfix, and in full-screen mode (which I presume cannot be automatically re-triggered when an auto-save + page refresh happens), there's a way for Redactor to pause autosaving.

My main question is CKEditor. With Redactor being deprecated, I had planned on transitioning over to CKE either under Craft 4.x or 5.x, but if CKE has no full-screen mode... is there a plugin that provides that functionality?

@brandonkelly
Copy link
Member

There are a couple third party plugins that add it, like this one, but I have no idea how reliably they are.

There’s an open feature request for it to be added as a first party plugin here.

@brandonkelly
Copy link
Member

Craft 4.10.0 and 5.2.0 are out, as well as Redactor 3.1.0 and 4.1.0.

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

No branches or pull requests

2 participants