Skip to content

Commit

Permalink
Fix memory leak when ColumnSet is used with Editor (#1455)
Browse files Browse the repository at this point in the history
* Fix issue with the Editor mixin resetting _alwaysOnWidgetColumns everything _configColumns is called.
* Throw error if Editor is mixed in before ColumnSet
* Update ColumnSet documentation with mixin order information

Co-authored-by: Ed Hager <[email protected]>
  • Loading branch information
msssk and edhager authored Apr 9, 2020
1 parent f5a8d95 commit 8d5d55c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ColumnSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ define([
// columns from each other. This mainly serves the purpose of allowing for
// column locking.

constructor: function () {
if ('_editorInstances' in this) {
throw new Error('When used with Editor ColumnSet must be mixed in before Editor.');
}
},

postCreate: function () {
var self = this;
this.inherited(arguments);
Expand Down
6 changes: 5 additions & 1 deletion Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,13 @@ define([
this._editorsPendingStartup = [];
},

configStructure: function () {
this._alwaysOnWidgetColumns = [];
this.inherited(arguments);
},

_configColumns: function () {
var columnArray = this.inherited(arguments);
this._alwaysOnWidgetColumns = [];
for (var i = 0, l = columnArray.length; i < l; i++) {
if (columnArray[i].editor) {
this._configureEditorColumn(columnArray[i]);
Expand Down
6 changes: 5 additions & 1 deletion doc/components/mixins/ColumnSet.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ The ColumnSet mixin supports the following additional instance methods.
### Method Summary
Method | Description
------ | -----------
`styleColumnSet(columnsetId, css)` | Programmatically adds styles to a columnset, by injecting a rule into a stylesheet in the document. Returns a handle with a `remove` function, which can be called to later remove the added style rule. Styles added via this method will be removed when the instance is destroyed if `cleanAddedRules` is set to `true`.
`styleColumnSet(columnsetId, css)` | Programmatically adds styles to a columnset, by injecting a rule into a stylesheet in the document. Returns a handle with a `remove` function, which can be called to later remove the added style rule. Styles added via this method will be removed when the instance is destroyed if `cleanAddedRules` is set to `true`.

## Mixin Order

`ColumnSet` must be mixed in **before** `Editor` when both are used together.

0 comments on commit 8d5d55c

Please sign in to comment.