? Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
17 Jul 2021

Pull Request for Issue #24343 .

Summary of Changes

Browser will clear iframe content when DOM changes, so we need to re-init the editor every time.
This fix only for Joomla 3.

Based on @ryandemmer idea, but more simple, without introducing new events.

Testing Instructions

Apply patch and please follow #24343

Actual result BEFORE applying this Pull Request

Editor lose the content

Expected result AFTER applying this Pull Request

Editor works

Documentation Changes Required

none

avatar Fedik Fedik - open - 17 Jul 2021
avatar Fedik Fedik - change - 17 Jul 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Jul 2021
Category JavaScript External Library
avatar Fedik
Fedik - comment - 17 Jul 2021

Drone fail with MySQL connection error, that not related to javascript changes

avatar richard67
richard67 - comment - 17 Jul 2021

Have restarted the drone and it seems it has helped.

avatar richard67 richard67 - test_item - 18 Jul 2021 - Tested successfully
avatar richard67
richard67 - comment - 18 Jul 2021

I have tested this item successfully on c0eea4f


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34808.

avatar ryandemmer
ryandemmer - comment - 19 Jul 2021

I would suggest that if you are going to use the "sortstop" event bound to the document object, then you check that it is actually sorting a subform, eg:

jQuery(document).on('sortstop', function (event, ui) {
    if (ui.item[0] && jQuery(ui.item[0]).is('.subform-repeatable-group')) {
        Joomla.JoomlaTinyMCE.setupEditors(ui.item[0]);
    }
});
avatar ryandemmer
ryandemmer - comment - 19 Jul 2021

Or better yet, bind to the subform container instead, eg:

jQuery(document).on('sortstop', '.subform-repeatable .ui-sortable', function (e, ui) {
    if (ui.item[0]) {
        Joomla.JoomlaTinyMCE.setupEditors(ui.item[0]);
    }
});
avatar Fedik
Fedik - comment - 19 Jul 2021

I thought about it, but from other hand it will help also for someone who use own jquery UI sorting with editor.
The main issue comes from jquery UI.

avatar ryandemmer
ryandemmer - comment - 19 Jul 2021

If you don't bind the event specfically to the subform, then the event will trigger whenever a sortable occurs, regardless of whether it is on a subform or not. This is inefficient and unnecessary, and could cause unforseen issues.

avatar Fedik
Fedik - comment - 19 Jul 2021

Not really, Joomla.JoomlaTinyMCE.setupEditors() will care about existing editor.

Using jQuery delegation just add one more if() in the chain.
In one or another way it will be the same if talk about efficiency ;)

then the event will trigger whenever a sortable occurs, regardless of whether it is on a subform or not.

And that is potential side effect (positive one), for people who use Editor with UI Sortable but not in subform.

avatar pixxelfactory
pixxelfactory - comment - 21 Jul 2021

I have tested it and there is an issue:
If you add a row and try to reorder it without saving the article first, the content disappears (tested with this repo with stock tinymce).
And it does not work at all using JCE (newest version, JCE Core).. =(

avatar Fedik
Fedik - comment - 21 Jul 2021

And it does not work at all using JCE

Please test with core TinyMCE editor,
JCE should implement its own fix, because it the editor issue

avatar ryandemmer
ryandemmer - comment - 21 Jul 2021

And it does not work at all using JCE (newest version, JCE Core).. =(

This will be fixed independantly in the next JCE update, as this current core fix cannot be applied to JCE.

avatar pixxelfactory
pixxelfactory - comment - 22 Jul 2021

Ok, done, it works, except in one case: If you add an editor and try to reorder it without saving the article first, in that case the content is emptied.

avatar Fedik
Fedik - comment - 22 Jul 2021

hmhm, I will check

avatar ryandemmer
ryandemmer - comment - 22 Jul 2021

It's a good idea to remove the editor first, before re-initialising it. This also saves the content to the textarea, which would prevent the content from dissappearing. See my comment here - #24343 (comment)

avatar Fedik
Fedik - comment - 23 Jul 2021

It's a good idea to remove the editor first, before re-initialising it.

It done here already.
On quick check it some random TinyMCE bug, happened when call editor.remove().
In most cases it works okay, but sometimes it cause TypeError: Cannot read property 'startContainer' of null

avatar zero-24 zero-24 - change - 17 Sep 2021
Labels Added: ?
avatar zero-24 zero-24 - test_item - 17 Sep 2021 - Tested successfully
avatar zero-24
zero-24 - comment - 17 Sep 2021

I have tested this item successfully on c7d466c

Works good to me thanks ?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/34808.

avatar zero-24
zero-24 - comment - 21 Nov 2021

Merging for now thanks @Fedik

avatar zero-24 zero-24 - close - 21 Nov 2021
avatar zero-24 zero-24 - merge - 21 Nov 2021
avatar zero-24 zero-24 - change - 21 Nov 2021
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-11-21 13:18:24
Closed_By zero-24

Add a Comment

Login with GitHub to post a comment