Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 45aae30

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
fix(editors): regression bug causing infinite loop in rare occasion
- calling getEditorLock() into the save() method when editor cell value is invalid was sometime causing infinite loop and so getEditorLock() should only be called when value is valid - also remove unused "commitEdit()" method, it wasn't called by anything
1 parent 41a1412 commit 45aae30

File tree

11 files changed

+67
-62
lines changed

11 files changed

+67
-62
lines changed

src/app/examples/custom-angularComponentEditor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ export class CustomAngularComponentEditor implements Editor {
9595
}
9696

9797
save() {
98-
if (this.hasAutoCommitEdit) {
99-
this.args.grid.getEditorLock().commitCurrentEdit();
100-
} else {
101-
this.args.commitChanges();
98+
const validation = this.validate();
99+
if (validation && validation.valid) {
100+
if (this.hasAutoCommitEdit) {
101+
this.args.grid.getEditorLock().commitCurrentEdit();
102+
} else {
103+
this.args.commitChanges();
104+
}
102105
}
103106
}
104107

src/app/examples/custom-inputEditor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ export class CustomInputEditor implements Editor {
9898
}
9999

100100
save() {
101-
if (this.hasAutoCommitEdit) {
102-
this.args.grid.getEditorLock().commitCurrentEdit();
103-
} else {
104-
this.args.commitChanges();
101+
const validation = this.validate();
102+
if (validation && validation.valid) {
103+
if (this.hasAutoCommitEdit) {
104+
this.args.grid.getEditorLock().commitCurrentEdit();
105+
} else {
106+
this.args.commitChanges();
107+
}
105108
}
106109
}
107110

src/app/examples/grid-editor.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,25 +178,26 @@ export class GridEditorComponent implements OnInit {
178178
sortable: true,
179179
type: FieldType.number,
180180
filter: { model: Filters.slider, params: { hideSliderNumber: false } },
181+
/*
181182
editor: {
182183
model: Editors.slider,
183184
minValue: 0,
184185
maxValue: 100,
185186
// params: { hideSliderNumber: true },
186187
},
187-
/*
188+
*/
188189
editor: {
189190
// default is 0 decimals, if no decimals is passed it will accept 0 or more decimals
190191
// however if you pass the "decimalPlaces", it will validate with that maximum
191192
alwaysSaveOnEnterKey: true, // defaults to False, when set to true and user presses ENTER it will always call a Save even if value is empty
192193
model: Editors.float,
193-
minValue: 0,
194+
minValue: 5,
194195
maxValue: 365,
195196
// the default validation error message is in English but you can override it by using "errorMessage"
196197
// errorMessage: this.i18n.tr('INVALID_FLOAT', { maxDecimal: 2 }),
197198
params: { decimalPlaces: 2 },
198199
},
199-
*/
200+
200201
}, {
201202
id: 'complete',
202203
name: '% Complete',

src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -340,28 +340,6 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
340340
});
341341
}
342342

343-
/**
344-
* Commits the current edit to the grid
345-
*/
346-
commitEdit(target: Element) {
347-
if (this.grid.getOptions().autoCommitEdit) {
348-
const activeNode = this.grid.getActiveCellNode();
349-
350-
// a timeout must be set or this could come into conflict when slickgrid
351-
// tries to commit the edit when going from one editor to another on the grid
352-
// through the click event. If the timeout was not here it would
353-
// try to commit/destroy the editor twice, which would throw a jquery
354-
// error about the element not being in the DOM
355-
setTimeout(() => {
356-
// make sure the target is the active editor so we do not
357-
// commit prematurely
358-
if (activeNode && activeNode.contains(target) && this.grid.getEditorLock().isActive()) {
359-
this.grid.getEditorLock().commitCurrentEdit();
360-
}
361-
});
362-
}
363-
}
364-
365343
/**
366344
* Define our internal Post Process callback, it will execute internally after we get back result from the Process backend call
367345
* For now, this is GraphQL Service ONLY feature and it will basically refresh the Dataset & Pagination without having the user to create his own PostProcess every time

src/app/modules/angular-slickgrid/editors/autoCompleteEditor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,13 @@ export class AutoCompleteEditor implements Editor {
133133
}
134134

135135
save() {
136-
if (this.hasAutoCommitEdit) {
137-
this.args.grid.getEditorLock().commitCurrentEdit();
138-
} else {
139-
this.args.commitChanges();
136+
const validation = this.validate();
137+
if (validation && validation.valid) {
138+
if (this.hasAutoCommitEdit) {
139+
this.args.grid.getEditorLock().commitCurrentEdit();
140+
} else {
141+
this.args.commitChanges();
142+
}
140143
}
141144
}
142145

src/app/modules/angular-slickgrid/editors/dateEditor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,13 @@ export class DateEditor implements Editor {
116116

117117
save() {
118118
// autocommit will not focus the next editor
119-
if (this.args.grid.getOptions().autoCommitEdit) {
120-
this.args.grid.getEditorLock().commitCurrentEdit();
121-
} else {
122-
this.args.commitChanges();
119+
const validation = this.validate();
120+
if (validation && validation.valid) {
121+
if (this.args.grid.getOptions().autoCommitEdit) {
122+
this.args.grid.getEditorLock().commitCurrentEdit();
123+
} else {
124+
this.args.commitChanges();
125+
}
123126
}
124127
}
125128

src/app/modules/angular-slickgrid/editors/floatEditor.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ export class FloatEditor implements Editor {
4848
this._lastInputEvent = event;
4949
if (event.keyCode === KeyCode.LEFT || event.keyCode === KeyCode.RIGHT) {
5050
event.stopImmediatePropagation();
51-
} else if (event.keyCode === KeyCode.ENTER) {
52-
event.stopImmediatePropagation();
53-
this.save();
5451
}
5552
});
5653

@@ -146,10 +143,13 @@ export class FloatEditor implements Editor {
146143
}
147144

148145
save() {
149-
if (this.hasAutoCommitEdit) {
150-
this.args.grid.getEditorLock().commitCurrentEdit();
151-
} else {
152-
this.args.commitChanges();
146+
const validation = this.validate();
147+
if (validation && validation.valid) {
148+
if (this.hasAutoCommitEdit) {
149+
this.args.grid.getEditorLock().commitCurrentEdit();
150+
} else {
151+
this.args.commitChanges();
152+
}
153153
}
154154
}
155155

src/app/modules/angular-slickgrid/editors/integerEditor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ export class IntegerEditor implements Editor {
103103
}
104104

105105
save() {
106-
if (this.hasAutoCommitEdit) {
107-
this.args.grid.getEditorLock().commitCurrentEdit();
108-
} else {
109-
this.args.commitChanges();
106+
const validation = this.validate();
107+
if (validation && validation.valid) {
108+
if (this.hasAutoCommitEdit) {
109+
this.args.grid.getEditorLock().commitCurrentEdit();
110+
} else {
111+
this.args.commitChanges();
112+
}
110113
}
111114
}
112115

src/app/modules/angular-slickgrid/editors/longTextEditor.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,13 @@ export class LongTextEditor implements Editor {
165165
}
166166

167167
save() {
168-
if (this.hasAutoCommitEdit) {
169-
this.args.grid.getEditorLock().commitCurrentEdit();
168+
const validation = this.validate();
169+
if (validation && validation.valid) {
170+
if (this.hasAutoCommitEdit) {
171+
this.args.grid.getEditorLock().commitCurrentEdit();
172+
} else {
173+
this.args.commitChanges();
174+
}
170175
} else {
171176
this.args.commitChanges();
172177
}

src/app/modules/angular-slickgrid/editors/sliderEditor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ export class SliderEditor implements Editor {
8282
}
8383

8484
save() {
85-
if (this.args.grid.getOptions().autoCommitEdit) {
86-
this.args.grid.getEditorLock().commitCurrentEdit();
87-
} else {
88-
this.args.commitChanges();
85+
const validation = this.validate();
86+
if (validation && validation.valid) {
87+
if (this.args.grid.getOptions().autoCommitEdit) {
88+
this.args.grid.getEditorLock().commitCurrentEdit();
89+
} else {
90+
this.args.commitChanges();
91+
}
8992
}
9093
}
9194

0 commit comments

Comments
 (0)