Skip to content

Commit 83a2034

Browse files
AG-16755 edit tab rich select editor expand (ag-grid#13311)
* AG-16805-add-newRawValue-to-cell-changed
1 parent c471997 commit 83a2034

2 files changed

Lines changed: 758 additions & 7 deletions

File tree

packages/ag-grid-community/src/edit/strategy/singleCellEditStrategy.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,14 @@ export class SingleCellEditStrategy extends BaseEditStrategy {
222222
// Don't start editing the next cell, focus only
223223
const suppressStartEditOnTab = this.gos.get('suppressStartEditOnTab');
224224

225+
let startEditingCalled = false;
225226
if (!rowsMatch && !preventNavigation) {
226227
super.cleanupEditors(nextCell, true);
227228

228229
if (suppressStartEditOnTab) {
229230
nextCell.focusCell(true, event);
230231
} else {
232+
startEditingCalled = true;
231233
this.editSvc.startEditing(nextCell, {
232234
startedEdit: true,
233235
event,
@@ -244,13 +246,17 @@ export class SingleCellEditStrategy extends BaseEditStrategy {
244246
if (suppressStartEditOnTab) {
245247
nextCell.focusCell(true, event);
246248
} else if (!nextCell.comp?.getCellEditor()) {
247-
// Two possibilities:
248-
// * Editor should be visible (but was destroyed due to column virtualisation)
249-
// = we shouldn't re-emit a startEdit event, so stay silent
250-
// * Editor wasn't created because edit came from API and didn't trigger EditService.startEditing
251-
// = shouldn't be silent
252-
const alreadyEditing = this.editSvc?.isEditing(nextCell, { withOpenEditor: true });
253-
_setupEditor(this.beans, nextCell, { event, cellStartedEdit: true, silent: alreadyEditing });
249+
// If startEditing was called above (cross-row navigation), the editor may not
250+
// exist yet because React creates editor components asynchronously. In that case
251+
// skip the redundant _setupEditor call to avoid overwriting the correctly-
252+
// parameterised first call. Otherwise, the editor is genuinely missing (e.g.
253+
// destroyed by column virtualisation while edit state remained open) and must
254+
// be re-created — silently if the cell is already in editing state to avoid
255+
// re-emitting cellEditingStarted.
256+
if (!startEditingCalled) {
257+
const alreadyEditing = this.editSvc?.isEditing(nextCell, { withOpenEditor: true });
258+
_setupEditor(this.beans, nextCell, { event, cellStartedEdit: true, silent: alreadyEditing });
259+
}
254260
this.setFocusInOnEditor(nextCell);
255261

256262
this.cleanupEditors(nextCell);

0 commit comments

Comments
 (0)