Skip to content

Commit

Permalink
Make clicking on the corner header select all nested headers. handson…
Browse files Browse the repository at this point in the history
…table#7096 (handsontable#7104)

* - Make clicking on the corner header select all nested headers. handsontable#7096
- Add a test case.

* - Remove the unneeded 'hot' variable from the test case. handsontable#7096
  • Loading branch information
jansiegel authored Jul 10, 2020
1 parent a2a52f2 commit 3a865cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/nestedHeaders/nestedHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class NestedHeaders extends BasePlugin {
const highlightHeader = classNameModifier(hotSettings.currentHeaderClassName);
const activeHeader = classNameModifier(hotSettings.activeHeaderClassName);

const selectionByHeader = hot.selection.isSelectedByColumnHeader();
const selectionByHeader = hot.selection.isSelectedByColumnHeader() || hot.selection.isSelectedByCorner();
const layersCount = this.#stateManager.getLayersCount();
const activeHeaderChanges = new Map();
const highlightHeaderChanges = new Map();
Expand Down
26 changes: 26 additions & 0 deletions src/plugins/nestedHeaders/test/nestedHeaders.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,32 @@ describe('NestedHeaders', () => {
expect(hot.getSelected()).toEqual([[-1, 3, hot.countRows() - 1, 6]]);
});

it('should select all column headers (on all levels) after clicking the corner header', function() {
handsontable({
data: Handsontable.helper.createSpreadsheetData(10, 10),
colHeaders: true,
rowHeaders: true,
nestedHeaders: [
['A', { label: 'B', colspan: 8 }, 'C'],
['D', { label: 'E', colspan: 4 }, { label: 'F', colspan: 4 }, 'G'],
['H', { label: 'I', colspan: 2 }, { label: 'J', colspan: 2 }, { label: 'K', colspan: 2 },
{ label: 'L', colspan: 2 }, 'M'],
['N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W']
]
});

const $cornerHeader = this.$container.find('.ht_clone_top_left_corner thead tr:eq(0) th:eq(0)');

$cornerHeader.simulate('mousedown');
$cornerHeader.simulate('mouseup');

expect(
$('.ht_clone_top thead tr th:not(:first-child)').filter(function() {
return !$(this).hasClass('hiddenHeader') && !$(this).hasClass('ht__active_highlight');
}).size()
).toEqual(0);
});

it('should add selection borders in the expected positions, when selecting multi-columned headers', function() {
handsontable({
data: Handsontable.helper.createSpreadsheetData(4, 10),
Expand Down

0 comments on commit 3a865cb

Please sign in to comment.