Skip to content

Commit

Permalink
Fix a problem, where it was impossible to open the filter dropdown, w…
Browse files Browse the repository at this point in the history
…hen multiple Handsontable instances were present on a page. (#6122)
  • Loading branch information
jansiegel committed Jul 17, 2019
1 parent f3d59dc commit f10cc71
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/plugins/contextMenu/menu.js
Expand Up @@ -560,9 +560,6 @@ class Menu {
className = `${this.options.className}Sub_${className}`;

container = rootDocument.querySelector(`.${this.options.className}.${className}`);

} else {
container = rootDocument.querySelector(`.${this.options.className}`);
}

if (!container) {
Expand Down
42 changes: 42 additions & 0 deletions src/plugins/filters/test/filtersUI.e2e.js
Expand Up @@ -1335,6 +1335,48 @@ describe('Filters UI', () => {
}, 100);
});

it('should allow opening the filtering dropdown menu, when there are multiple Handsontable instances present', () => {
handsontable({
data: getDataForFilters(),
columns: getColumnsForFilters(),
filters: true,
dropdownMenu: true,
width: 500,
height: 300
});

const hot2Container = document.createElement('DIV');
document.body.appendChild(hot2Container);
const hot2 = new Handsontable(hot2Container, {
data: getDataForFilters(),
columns: getColumnsForFilters(),
filters: true,
dropdownMenu: true,
width: 500,
height: 300
});

expect(document.querySelectorAll('.htDropdownMenu').length).toBe(2);

dropdownMenu(1);
closeDropdownMenu();

expect(getPlugin('dropdownMenu').menu.container.style.display).toBe('block');
expect(getPlugin('dropdownMenu').menu.container.parentElement).not.toBe(null);

const th = hot2.view.wt.wtTable.getColumnHeader(1);
const button = th.querySelector('.changeType');
$(button).simulate('mousedown');
$(button).simulate('mouseup');
$(button).simulate('click');

expect(hot2.getPlugin('dropdownMenu').menu.container.style.display).toBe('block');
expect(hot2.getPlugin('dropdownMenu').menu.container.parentElement).not.toBe(null);

hot2.destroy();
hot2Container.parentElement.removeChild(hot2Container);
});

describe('Simple filtering (one column)', () => {
it('should filter empty values and revert back after removing filter', () => {
handsontable({
Expand Down

0 comments on commit f10cc71

Please sign in to comment.