Skip to content

Commit 797ff45

Browse files
authored
fix(common): support Shift-click cell range selection (#2757)
1 parent 10ce3a8 commit 797ff45

14 files changed

Lines changed: 155 additions & 26 deletions

File tree

‎demos/aurelia/test/cypress/e2e/example48.cy.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ describe('Example 48 - Hybrid Selection Model', () => {
191191
.then((text) => expect(text.match(/"fromRow"/g)).to.have.length(2));
192192
cy.get('[data-test="enable-multi-selection"]').should('be.checked');
193193
});
194+
195+
it('should select a rectangular cell range when Shift-clicking another cell', () => {
196+
cy.get('#grid48-1 .slick-row[data-row="1"] .slick-cell.l1.r1').click();
197+
cy.get('#grid48-1 .slick-row[data-row="3"] .slick-cell.l3.r3').click({ shiftKey: true });
198+
199+
cy.get('#grid48-1 .slick-cell.selected').should('have.length', 9);
200+
cy.get('#selectionRange1').should('have.text', '{"fromRow":1,"fromCell":1,"toRow":3,"toCell":3}');
201+
});
202+
194203
it('should preserve row and column offsets when copying multiple cell ranges', () => {
195204
cy.get('#grid48-1 .slick-viewport-top.slick-viewport-left').scrollTo('top');
196205
cy.get('[data-test="enable-multi-selection"]').should('be.checked');

‎demos/react/test/cypress/e2e/example48.cy.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ describe('Example 48 - Hybrid Selection Model', () => {
191191
.then((text) => expect(text.match(/"fromRow"/g)).to.have.length(2));
192192
cy.get('[data-test="enable-multi-selection"]').should('be.checked');
193193
});
194+
195+
it('should select a rectangular cell range when Shift-clicking another cell', () => {
196+
cy.get('#grid48-1 .slick-row[data-row="1"] .slick-cell.l1.r1').click();
197+
cy.get('#grid48-1 .slick-row[data-row="3"] .slick-cell.l3.r3').click({ shiftKey: true });
198+
199+
cy.get('#grid48-1 .slick-cell.selected').should('have.length', 9);
200+
cy.get('#selectionRange1').should('have.text', '{"fromRow":1,"fromCell":1,"toRow":3,"toCell":3}');
201+
});
202+
194203
it('should preserve row and column offsets when copying multiple cell ranges', () => {
195204
cy.get('#grid48-1 .slick-viewport-top.slick-viewport-left').scrollTo('top');
196205
cy.get('[data-test="enable-multi-selection"]').should('be.checked');

‎demos/vanilla/src/examples/example19.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ <h5 class="mb-3 italic example-details">
2828
outputs of the selected cells. This also applies if the cells editor is already open due to use of
2929
<code>copyActiveEditorCell</code>
3030
</p>
31+
<p>Click a cell, then hold Shift and click another cell to select the rectangular range between them.</p>
3132
</h5>
3233
<h6 class="title is-6">
3334
<button class="button is-small" onclick.trigger="undoLastEdit()" data-test="undo-last-edit-btn">

‎demos/vanilla/src/examples/example37.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ <h5 class="mb-3 italic example-details">
3131
<code>rowSelectColumnIds: ['id']</code> as the columns that will trigger row selection.
3232
</li>
3333
<li>2. clicking on the any other columns will use <code>CellSelectionModel</code> by default</li>
34+
<li>3. with cell selection, hold Shift and click another cell to select the rectangular range between the two cells</li>
3435
</ul>
3536
</h5>
3637

‎demos/vue/test/cypress/e2e/example48.cy.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ describe('Example 48 - Hybrid Selection Model', () => {
191191
.then((text) => expect(text.match(/"fromRow"/g)).to.have.length(2));
192192
cy.get('[data-test="enable-multi-selection"]').should('be.checked');
193193
});
194+
195+
it('should select a rectangular cell range when Shift-clicking another cell', () => {
196+
cy.get('#grid48-1 .slick-row[data-row="1"] .slick-cell.l1.r1').click();
197+
cy.get('#grid48-1 .slick-row[data-row="3"] .slick-cell.l3.r3').click({ shiftKey: true });
198+
199+
cy.get('#grid48-1 .slick-cell.selected').should('have.length', 9);
200+
cy.get('#selectionRange1').should('have.text', '{"fromRow":1,"fromCell":1,"toRow":3,"toCell":3}');
201+
});
202+
194203
it('should preserve row and column offsets when copying multiple cell ranges', () => {
195204
cy.get('#grid48-1 .slick-viewport-top.slick-viewport-left').scrollTo('top');
196205
cy.get('[data-test="enable-multi-selection"]').should('be.checked');

‎frameworks/angular-slickgrid/docs/grid-functionalities/row-selection.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ selectionOptions: {
268268
}
269269
```
270270

271+
With cell selection enabled, click an anchor cell and then Shift-click another cell to select the rectangular range between them. In row-selection mode, Shift-click selects all rows between the anchor and clicked row.
272+
271273
For non-contiguous selection ranges, set `selectionOptions.enableMultiSelection: true`. Ctrl/Cmd-click toggles the clicked cell or row, and Ctrl/Cmd-drag adds another range. In row-selection mode, `multiSelect` continues to control whether multiple rows are allowed.
272274

273275
When `enableExcelCopyBuffer` is enabled, copying multiple non-contiguous ranges preserves their relative row and column positions in a single rectangular clipboard block; unselected cells inside the bounding rectangle remain blank.

‎frameworks/angular-slickgrid/test/cypress/e2e/example48.cy.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ describe('Example 48 - Hybrid Selection Model', () => {
191191
.then((text) => expect(text.match(/"fromRow"/g)).to.have.length(2));
192192
cy.get('[data-test="enable-multi-selection"]').should('be.checked');
193193
});
194+
195+
it('should select a rectangular cell range when Shift-clicking another cell', () => {
196+
cy.get('#grid48-1 .slick-row[data-row="1"] .slick-cell.l1.r1').click();
197+
cy.get('#grid48-1 .slick-row[data-row="3"] .slick-cell.l3.r3').click({ shiftKey: true });
198+
199+
cy.get('#grid48-1 .slick-cell.selected').should('have.length', 9);
200+
cy.get('#selectionRange1').should('have.text', '{"fromRow":1,"fromCell":1,"toRow":3,"toCell":3}');
201+
});
202+
194203
it('should preserve row and column offsets when copying multiple cell ranges', () => {
195204
cy.get('#grid48-1 .slick-viewport-top.slick-viewport-left').scrollTo('top');
196205
cy.get('[data-test="enable-multi-selection"]').should('be.checked');

‎frameworks/aurelia-slickgrid/docs/grid-functionalities/row-selection.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ selectionOptions: {
280280
}
281281
```
282282

283+
With cell selection enabled, click an anchor cell and then Shift-click another cell to select the rectangular range between them. In row-selection mode, Shift-click selects all rows between the anchor and clicked row.
284+
283285
For non-contiguous selection ranges, set `selectionOptions.enableMultiSelection: true`. Ctrl/Cmd-click toggles the clicked cell or row, and Ctrl/Cmd-drag adds another range. In row-selection mode, `multiSelect` continues to control whether multiple rows are allowed.
284286

285287
When `enableExcelCopyBuffer` is enabled, copying multiple non-contiguous ranges preserves their relative row and column positions in a single rectangular clipboard block; unselected cells inside the bounding rectangle remain blank.

‎frameworks/slickgrid-react/docs/grid-functionalities/row-selection.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ selectionOptions: {
361361
}
362362
```
363363

364+
With cell selection enabled, click an anchor cell and then Shift-click another cell to select the rectangular range between them. In row-selection mode, Shift-click selects all rows between the anchor and clicked row.
365+
364366
For non-contiguous selection ranges, set `selectionOptions.enableMultiSelection: true`. Ctrl/Cmd-click toggles the clicked cell or row, and Ctrl/Cmd-drag adds another range. In row-selection mode, `multiSelect` continues to control whether multiple rows are allowed.
365367

366368
When `enableExcelCopyBuffer` is enabled, copying multiple non-contiguous ranges preserves their relative row and column positions in a single rectangular clipboard block; unselected cells inside the bounding rectangle remain blank.

‎frameworks/slickgrid-vue/docs/grid-functionalities/row-selection.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ selectionOptions: {
431431
}
432432
```
433433

434+
With cell selection enabled, click an anchor cell and then Shift-click another cell to select the rectangular range between them. In row-selection mode, Shift-click selects all rows between the anchor and clicked row.
435+
434436
For non-contiguous selection ranges, set `selectionOptions.enableMultiSelection: true`. Ctrl/Cmd-click toggles the clicked cell or row, and Ctrl/Cmd-drag adds another range. In row-selection mode, `multiSelect` continues to control whether multiple rows are allowed.
435437

436438
When `enableExcelCopyBuffer` is enabled, copying multiple non-contiguous ranges preserves their relative row and column positions in a single rectangular clipboard block; unselected cells inside the bounding rectangle remain blank.

0 commit comments

Comments
 (0)