Skip to content

Commit

Permalink
Fix a problem with the dropdown editor throwing an error when the cel…
Browse files Browse the repository at this point in the history
…l value was represented by a `td` outside of the initial editor viewport. (#10763)

* Change the `afterSelection` to `afterSelectionEnd` hook callback in the autocomplete editor instance to allow targeting the `td` element.

* Add the changelog entry and a ref comment to the test case.
  • Loading branch information
jansiegel committed Feb 5, 2024
1 parent 5787854 commit 49293f5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .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"
}
Expand Up @@ -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);

Expand Down
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 49293f5

Please sign in to comment.