Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem with the dropdown editor throwing an error when the cell value was represented by a td outside of the initial editor viewport. #10763

Merged
merged 3 commits into from Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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