10000 Fixed browser freezing on cms toolbar markup refresh after plugin edit by nichoski · Pull Request #7070 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

Fixed browser freezing on cms toolbar markup refresh after plugin edit #7070

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cms/static/cms/js/dist/3.8.0/bundle.toolbar.min.js

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions cms/static/cms/js/modules/cms.toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import Navigation from './cms.navigation';
import Sideframe from './cms.sideframe';
import Modal from './cms.modal';
import Plugin from './cms.plugins';
import DiffDOM from 'diff-dom';
import { filter, throttle, uniq } from 'lodash';
import { showLoader, hideLoader } from './loader';
import { Helpers, KEYS } from './cms.base';

var SECOND = 1000;
var TOOLBAR_OFFSCREEN_OFFSET = 10; // required to hide box-shadow
var dd;

export const getPlaceholderIds = pluginRegistry =>
uniq(filter(pluginRegistry, ([, opts]) => opts.type === 'placeholder').map(([, opts]) => opts.placeholder_id));
Expand Down Expand Up @@ -99,18 +97,6 @@ var Toolbar = new Class({

// set a state to determine if we need to reinitialize this._events();
this.ui.toolbar.data('ready', true);

dd = new DiffDOM({
preDiffApply(info) {
if (
(info.diff.action === 'removeAttribute' || info.diff.action === 'modifyAttribute') &&
info.diff.name === 'style' &&
$('.cms-toolbar').is(info.node)
) {
return true;
}
}
});
},

/**
Expand Down Expand Up @@ -749,9 +735,8 @@ var Toolbar = new Class({

_refreshMarkup: function(newToolbar) {
const switcher = this.ui.toolbarSwitcher.detach();
const diff = dd.diff(this.ui.toolbar[0], newToolbar[0]);

dd.apply(this.ui.toolbar[0], diff);
$(this.ui.toolbar[0]).replaceWith(newToolbar[0]);

$('.cms-toolbar-item-cms-mode-switcher').replaceWith(switcher);

Expand Down
2 changes: 0 additions & 2 deletions cms/tests/frontend/unit/cms.toolbar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,6 @@ describe('CMS.Toolbar', function () {
expect(toolbar._setupUI).toHaveBeenCalledTimes(1);
expect(toolbar._events).toHaveBeenCalledTimes(1);
expect(toolbar.navigation instanceof FakeNavigation).toEqual(true);
expect(DiffDOM.prototype.diff).toHaveBeenCalledTimes(1);
expect(DiffDOM.prototype.apply).toHaveBeenCalledTimes(1);
expect(trigger).toHaveBeenCalledWith('resize');
expect(CMS.API.Clipboard._toolbarEvents).toHaveBeenCalledTimes(1);
});
Expand Down
0