diff --git a/.changelogs/10763.json b/.changelogs/10763.json new file mode 100644 index 00000000000..562b4c7c6f8 --- /dev/null +++ b/.changelogs/10763.json @@ -0,0 +1,8 @@ +{ + "issuesOrigin": "private", + "title": "Fixed a problem with the dropdown editor throwing an error when the cell value was represented by a `td` outside of the initial editor viewport.", + "type": "fixed", + "issueOrPR": 10763, + "breaking": false, + "framework": "none" +} diff --git a/handsontable/src/editors/autocompleteEditor/autocompleteEditor.js b/handsontable/src/editors/autocompleteEditor/autocompleteEditor.js index 61e5460d64a..ce65271c30e 100644 --- a/handsontable/src/editors/autocompleteEditor/autocompleteEditor.js +++ b/handsontable/src/editors/autocompleteEditor/autocompleteEditor.js @@ -187,7 +187,7 @@ export class AutocompleteEditor extends HandsontableEditor { TD.innerHTML = cellValue; }, - afterSelection: (startRow, startCol) => { + afterSelectionEnd: (startRow, startCol) => { if (rootInstanceAriaTagsEnabled) { const TD = this.htEditor.getCell(startRow, startCol, true); diff --git a/handsontable/src/editors/dropdownEditor/__tests__/dropdownEditor.spec.js b/handsontable/src/editors/dropdownEditor/__tests__/dropdownEditor.spec.js index 372342fb595..1d854d1ab62 100644 --- a/handsontable/src/editors/dropdownEditor/__tests__/dropdownEditor.spec.js +++ b/handsontable/src/editors/dropdownEditor/__tests__/dropdownEditor.spec.js @@ -319,6 +319,43 @@ describe('DropdownEditor', () => { window.onerror = prevError; }); + + // https://github.com/handsontable/dev-handsontable/issues/1724 + it('should not throw any errors after opening the editor, when the saved value is represented by a option-cell ' + + 'outside of the editor\'s initially loaded viewport', async() => { + const spy = jasmine.createSpyObj('error', ['test']); + const prevError = window.onerror; + + window.onerror = function() { + spy.test(); + }; + + handsontable({ + data: [['49']], + columns: [ + { + editor: 'dropdown', + source: (() => { + const arr = []; + + for (let i = 0; i < 50; i++) { + arr.push(`${i}`); + } + + return arr; + })(), + } + ] + }); + + selectCell(0, 0); + keyDownUp('enter'); + await sleep(100); + + expect(spy.test).not.toHaveBeenCalled(); + + window.onerror = prevError; + }); }); describe('closing the editor', () => {