MCPcopy
hub / github.com/handsontable/handsontable / setRangeEnd

Method setRangeEnd

handsontable/src/selection/selection.ts:421–499  ·  view source on GitHub ↗

* Ends selection range on given coordinate object. * * @param {CellCoords} coords Visual coords. * @param {number} [layerIndex] The layer index to set the end on. If not provided, the current layer level is used.

(coords: CellCoords, layerIndex = this.getLayerLevel())

Source from the content-addressed store, hash-verified

419 * @param {number} [layerIndex] The layer index to set the end on. If not provided, the current layer level is used.
420 */
421 setRangeEnd(coords: CellCoords, layerIndex = this.getLayerLevel()) {
422 if (this.selectedRange.isEmpty()) {
423 return;
424 }
425
426 this.setActiveSelectionLayerIndex(layerIndex);
427
428 const coordsClone = coords.clone();
429 const countRows = this.tableProps.countRows();
430 const countCols = this.tableProps.countCols();
431 const isSingle = this.getActiveSelectedRange()?.clone().setTo(coords).isSingleHeader();
432
433 // Ignore processing the end range when the header selection starts overlapping the corner and
434 // the selection is not a single header highlight.
435 if ((countRows > 0 || countCols > 0) &&
436 (countRows === 0 && (coordsClone.col ?? 0) < 0 && !isSingle ||
437 countCols === 0 && (coordsClone.row ?? 0) < 0 && !isSingle)) {
438 return;
439 }
440
441 this.runLocalHooks('beforeSetRangeEnd', coordsClone);
442 this.begin();
443
444 const cellRange = this.getActiveSelectedRange();
445
446 if (!cellRange) {
447 return;
448 }
449
450 if (!this.settings.navigableHeaders) {
451 cellRange.highlight.normalize();
452 }
453
454 if (this.settings.selectionMode === 'single') {
455 cellRange.setFrom(cellRange.highlight);
456 cellRange.setTo(cellRange.highlight);
457
458 } else {
459 const horizontalDir = cellRange.getHorizontalDirection();
460 const verticalDir = cellRange.getVerticalDirection();
461 const isMultiple = this.isMultiple();
462
463 cellRange.setTo(coordsClone);
464
465 if (
466 isMultiple &&
467 (horizontalDir !== cellRange.getHorizontalDirection() ||
468 cellRange.getWidth() === 1 && !cellRange.includes(cellRange.highlight))
469 ) {
470 cellRange.from.assign({
471 col: cellRange.highlight.col ?? undefined
472 });
473 }
474 if (
475 isMultiple &&
476 (verticalDir !== cellRange.getVerticalDirection() ||
477 cellRange.getHeight() === 1 && !cellRange.includes(cellRange.highlight))
478 ) {

Callers 15

setRangeStartMethod · 0.95
transformEndMethod · 0.95
shiftRowsMethod · 0.95
shiftColumnsMethod · 0.95
selectAllMethod · 0.95
selectCellsMethod · 0.95
selectColumnsMethod · 0.95
selectRowsMethod · 0.95
refreshMethod · 0.95
mouseDownFunction · 0.80
mouseOverFunction · 0.80

Calls 15

getLayerLevelMethod · 0.95
beginMethod · 0.95
isMultipleMethod · 0.95
setRangeFocusMethod · 0.95
applyAndCommitMethod · 0.95
isSingleHeaderMethod · 0.80
setToMethod · 0.80
setFromMethod · 0.80
getVerticalDirectionMethod · 0.80

Tested by

no test coverage detected