-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintain focus after column collapsing (#10865)
- Loading branch information
Showing
4 changed files
with
340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"issuesOrigin": "private", | ||
"title": "Maintain focus after column collapsing.", | ||
"type": "fixed", | ||
"issueOrPR": 10865, | ||
"breaking": false, | ||
"framework": "none" | ||
} |
123 changes: 123 additions & 0 deletions
123
handsontable/src/plugins/collapsibleColumns/__tests__/rtl/selection.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
describe('CollapsibleColumns (RTL mode)', () => { | ||
const id = 'testContainer'; | ||
|
||
beforeEach(function() { | ||
$('html').attr('dir', 'rtl'); | ||
this.$container = $(`<div id="${id}"></div>`).appendTo('body'); | ||
}); | ||
|
||
afterEach(function() { | ||
$('html').attr('dir', 'ltr'); | ||
|
||
if (this.$container) { | ||
destroy(); | ||
this.$container.remove(); | ||
} | ||
if (this.$wrapper) { | ||
this.$wrapper.remove(); | ||
} | ||
}); | ||
|
||
describe('selection', () => { | ||
it('should move focus to the nearest left column after collapsing (single cell selection)', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(3, 10), | ||
colHeaders: true, | ||
nestedHeaders: [ | ||
['A1', { label: 'B1', colspan: 5 }, 'G1', 'H1', 'I1', 'J1'], | ||
['A2', { label: 'B2', colspan: 4 }, 'F2', 'G2', 'H2', 'I2', 'J2'], | ||
['A3', 'B3', { label: 'C3', colspan: 3 }, 'F3', 'G3', 'H3', 'I3', 'J3'], | ||
], | ||
collapsibleColumns: true, | ||
}); | ||
|
||
selectCell(1, 3); | ||
$(getCell(-1, 2).querySelector('.collapsibleIndicator')) // Collapse header "C3" | ||
.simulate('mousedown') | ||
.simulate('mouseup') | ||
.simulate('click'); | ||
|
||
expect(` | ||
| : : : : : | | ||
| : : : : : : | | ||
| : : : : - : : : | | ||
|===:===:===:===:===:===:===:===| | ||
| : : : : : : : | | ||
| : : : : # : : : | | ||
| : : : : : : : | | ||
`).toBeMatchToSelectionPattern(); | ||
expect(getSelectedRange()).toEqualCellRange(['highlight: 1,5 from: 1,5 to: 1,5']); | ||
|
||
$(getCell(-1, 2).querySelector('.collapsibleIndicator')) // Expand header "C3" | ||
.simulate('mousedown') | ||
.simulate('mouseup') | ||
.simulate('click'); | ||
|
||
expect(` | ||
| : : : : : | | ||
| : : : : : : | | ||
| : : : : - : : : | | ||
|===:===:===:===:===:===:===:===:===:===| | ||
| : : : : : : : : : | | ||
| : : : : # : : : : : | | ||
| : : : : : : : : : | | ||
`).toBeMatchToSelectionPattern(); | ||
expect(getSelectedRange()).toEqualCellRange(['highlight: 1,5 from: 1,5 to: 1,5']); | ||
}); | ||
|
||
it('should move focus to the nearest right column when there is no column visible on the left after collapsing', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(3, 10), | ||
colHeaders: true, | ||
nestedHeaders: [ | ||
['A1', { label: 'B1', colspan: 5 }, 'G1', 'H1', 'I1', 'J1'], | ||
['A2', { label: 'B2', colspan: 5 }, 'F2', 'G2', 'H2', 'I2', 'J2'], | ||
['A3', 'B3', { label: 'C3', colspan: 4 }, 'F3', 'G3', 'H3', 'I3', 'J3'], | ||
], | ||
collapsibleColumns: true, | ||
}); | ||
|
||
const columnMapper = columnIndexMapper().createAndRegisterIndexMap('my-hiding-map', 'hiding'); | ||
|
||
columnMapper.setValueAtIndex(6, true); | ||
columnMapper.setValueAtIndex(7, true); | ||
columnMapper.setValueAtIndex(8, true); | ||
columnMapper.setValueAtIndex(9, true); | ||
|
||
render(); | ||
|
||
selectCell(1, 3, 2, 5); | ||
$(getCell(-3, 1).querySelector('.collapsibleIndicator')) // Collapse header "B1" | ||
.simulate('mousedown') | ||
.simulate('mouseup') | ||
.simulate('click'); | ||
|
||
expect(` | ||
| : | | ||
| : | | ||
| - : | | ||
|===:===| | ||
| : | | ||
| # : | | ||
| : | | ||
`).toBeMatchToSelectionPattern(); | ||
expect(getSelectedRange()).toEqualCellRange(['highlight: 1,1 from: 1,1 to: 1,1']); | ||
|
||
$(getCell(-3, 1).querySelector('.collapsibleIndicator')) // Expand header "B1" | ||
.simulate('mousedown') | ||
.simulate('mouseup') | ||
.simulate('click'); | ||
|
||
expect(` | ||
| : | | ||
| : | | ||
| : - : | | ||
|===:===:===:===:===:===| | ||
| : : : : : | | ||
| : : : : # : | | ||
| : : : : : | | ||
`).toBeMatchToSelectionPattern(); | ||
expect(getSelectedRange()).toEqualCellRange(['highlight: 1,1 from: 1,1 to: 1,1']); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters