handsontable 18.1.2 → 18.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/3rdparty/walkontable/src/selection/border/border.d.ts +46 -3
  2. package/3rdparty/walkontable/src/selection/border/border.js +76 -37
  3. package/3rdparty/walkontable/src/selection/border/border.mjs +76 -37
  4. package/3rdparty/walkontable/src/selection/manager.js +16 -6
  5. package/3rdparty/walkontable/src/selection/manager.mjs +16 -6
  6. package/CHANGELOG.md +5 -0
  7. package/base.js +2 -2
  8. package/base.mjs +2 -2
  9. package/dist/handsontable.full.js +110 -54
  10. package/dist/handsontable.full.min.js +8 -8
  11. package/dist/handsontable.js +110 -54
  12. package/dist/handsontable.min.js +103 -103
  13. package/dist/themes/classic.js +2 -2
  14. package/dist/themes/classic.min.js +2 -2
  15. package/dist/themes/horizon.js +2 -2
  16. package/dist/themes/horizon.min.js +2 -2
  17. package/dist/themes/main.js +2 -2
  18. package/dist/themes/main.min.js +2 -2
  19. package/dist/themes/static/variables/colors/ant.js +2 -2
  20. package/dist/themes/static/variables/colors/ant.min.js +2 -2
  21. package/dist/themes/static/variables/colors/classic.js +2 -2
  22. package/dist/themes/static/variables/colors/classic.min.js +2 -2
  23. package/dist/themes/static/variables/colors/horizon.js +2 -2
  24. package/dist/themes/static/variables/colors/horizon.min.js +2 -2
  25. package/dist/themes/static/variables/colors/main.js +2 -2
  26. package/dist/themes/static/variables/colors/main.min.js +2 -2
  27. package/dist/themes/static/variables/colors/material.js +2 -2
  28. package/dist/themes/static/variables/colors/material.min.js +2 -2
  29. package/dist/themes/static/variables/colors/shadcn.js +2 -2
  30. package/dist/themes/static/variables/colors/shadcn.min.js +2 -2
  31. package/dist/themes/static/variables/density.js +2 -2
  32. package/dist/themes/static/variables/density.min.js +2 -2
  33. package/dist/themes/static/variables/helpers/iconsMap.js +2 -2
  34. package/dist/themes/static/variables/helpers/iconsMap.min.js +2 -2
  35. package/dist/themes/static/variables/icons/horizon.js +2 -2
  36. package/dist/themes/static/variables/icons/horizon.min.js +2 -2
  37. package/dist/themes/static/variables/icons/main.js +2 -2
  38. package/dist/themes/static/variables/icons/main.min.js +2 -2
  39. package/dist/themes/static/variables/sizing.js +2 -2
  40. package/dist/themes/static/variables/sizing.min.js +2 -2
  41. package/dist/themes/static/variables/tokens/classic.js +2 -2
  42. package/dist/themes/static/variables/tokens/classic.min.js +2 -2
  43. package/dist/themes/static/variables/tokens/horizon.js +2 -2
  44. package/dist/themes/static/variables/tokens/horizon.min.js +2 -2
  45. package/dist/themes/static/variables/tokens/main.js +2 -2
  46. package/dist/themes/static/variables/tokens/main.min.js +2 -2
  47. package/helpers/mixed.js +5 -5
  48. package/helpers/mixed.mjs +5 -5
  49. package/package.json +1 -1
  50. package/styles/handsontable.css +2 -2
  51. package/styles/handsontable.min.css +2 -2
  52. package/styles/handsontableStyles.js +1 -1
  53. package/styles/handsontableStyles.mjs +1 -1
  54. package/styles/ht-icons-horizon.min.css +2 -2
  55. package/styles/ht-icons-main.min.css +2 -2
  56. package/styles/ht-theme-classic-no-icons.min.css +2 -2
  57. package/styles/ht-theme-classic.min.css +2 -2
  58. package/styles/ht-theme-horizon-no-icons.min.css +2 -2
  59. package/styles/ht-theme-horizon.min.css +2 -2
  60. package/styles/ht-theme-main-no-icons.min.css +2 -2
  61. package/styles/ht-theme-main.min.css +2 -2
  62. package/utils/licenseBranding/index.js +2 -2
  63. package/utils/licenseBranding/index.mjs +2 -2
  64. package/utils/licenseNotification.js +2 -2
  65. package/utils/licenseNotification.mjs +2 -2
@@ -1,6 +1,27 @@
1
1
  import type { WalkontableInstance } from '../../types';
2
2
  import type EventManager from '../../../../../eventManager';
3
3
  import type { BorderInstanceSettings, CornerDefaultStyle, SelectionHandles, AdjustHandles, MoveZone } from './types';
4
+ /**
5
+ * Everything `Border#paint()` needs, read by `Border#measure()` before any border writes a style.
6
+ */
7
+ interface BorderMeasurement {
8
+ toRow: number;
9
+ toColumn: number;
10
+ toTDEl: HTMLElement;
11
+ toOffset: {
12
+ top: number;
13
+ left: number;
14
+ };
15
+ isRtl: boolean;
16
+ top: number;
17
+ inlineStartPos: number;
18
+ width: number;
19
+ height: number;
20
+ tableSize: {
21
+ width: number;
22
+ height: number;
23
+ } | null;
24
+ }
4
25
  /**
5
26
  *
6
27
  */
@@ -193,8 +214,13 @@ declare class Border {
193
214
  * @param {number} left The left position of the handler.
194
215
  * @param {number} width The width of the handler.
195
216
  * @param {number} height The height of the handler.
217
+ * @param {{width: number, height: number}|null} [tableSize] The table size `measure()` read, so the
218
+ * handles are positioned without a geometry read between style writes.
196
219
  */
197
- updateMultipleSelectionHandlesPosition(row: number, col: number, top: number, left: number, width: number, height: number): void;
220
+ updateMultipleSelectionHandlesPosition(row: number, col: number, top: number, left: number, width: number, height: number, tableSize?: {
221
+ width: number;
222
+ height: number;
223
+ } | null): void;
198
224
  /**
199
225
  * Tells whether a selection edge lands exactly on a frozen-pane boundary and is therefore owned by
200
226
  * the frozen overlay. Depends only on the fixed-pane settings and the raw corner, so every overlay
@@ -427,7 +453,23 @@ declare class Border {
427
453
  */
428
454
  isCornerLiftedAtBlockEnd(toRow: number, anchorTop: number, TD: HTMLElement, trimmingContainer: HTMLElement | Window): boolean;
429
455
  /**
430
- * Show border around one or many cells.
456
+ * Show border around one or many cells: {@link Border#measure} first, then {@link Border#paint}.
457
+ * A pass over many borders measures all of them before painting any (see `SelectionManager#render`).
458
+ *
459
+ * @param {Array} corners The corner coordinates.
460
+ */
461
+ appear(corners: number[]): void;
462
+ /**
463
+ * Reads every piece of geometry {@link Border#paint} needs. It must not write to the DOM: a write
464
+ * between two geometry reads forces the browser to lay the table out again, and a pass over
465
+ * thousands of borders then costs one layout per border.
466
+ *
467
+ * @param {Array} corners The corner coordinates.
468
+ * @returns {BorderMeasurement|null} The measurement, or `null` when nothing is to be drawn.
469
+ */
470
+ measure(corners: number[]): BorderMeasurement | null;
471
+ /**
472
+ * Writes the border from the measurement {@link Border#measure} took.
431
473
  *
432
474
  * The fill handle is normally centered on the selection's bottom-end corner, so half of it hangs
433
475
  * past that corner. Where that overhang cannot survive — a container edge, or a frozen pane that
@@ -436,8 +478,9 @@ declare class Border {
436
478
  * {@link Border#isCornerLiftedAtBlockEnd} for which edges those are.
437
479
  *
438
480
  * @param {Array} corners The corner coordinates.
481
+ * @param {BorderMeasurement|null} measurement The measurement, or `null` to hide the border.
439
482
  */
440
- appear(corners: number[]): void;
483
+ paint(corners: number[], measurement: BorderMeasurement | null): void;
441
484
  /**
442
485
  * Check whether an entire column of cells is selected.
443
486
  *
@@ -419,15 +419,17 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
419
419
  * @param {number} left The left position of the handler.
420
420
  * @param {number} width The width of the handler.
421
421
  * @param {number} height The height of the handler.
422
- */ updateMultipleSelectionHandlesPosition(row, col, top, left, width, height) {
422
+ * @param {{width: number, height: number}|null} [tableSize] The table size `measure()` read, so the
423
+ * handles are positioned without a geometry read between style writes.
424
+ */ updateMultipleSelectionHandlesPosition(row, col, top, left, width, height, tableSize = null) {
423
425
  const isRtl = this.wot.wtSettings.getSetting('rtlMode');
424
426
  const inlinePosProperty = isRtl ? 'right' : 'left';
425
427
  const { top: topStyles, topHitArea: topHitAreaStyles, bottom: bottomStyles, bottomHitArea: bottomHitAreaStyles } = this.selectionHandles.styles;
426
428
  const handleBorderSize = parseInt(topStyles.borderWidth, 10);
427
429
  const handleSize = parseInt(topStyles.width, 10);
428
430
  const hitAreaSize = parseInt(topHitAreaStyles.width, 10);
429
- const totalTableWidth = this.wot.wtTable.getWidth();
430
- const totalTableHeight = this.wot.wtTable.getHeight();
431
+ const totalTableWidth = tableSize?.width ?? this.wot.wtTable.getWidth();
432
+ const totalTableHeight = tableSize?.height ?? this.wot.wtTable.getHeight();
431
433
  topStyles.top = `${parseInt(String(top - handleSize - 1), 10)}px`;
432
434
  topStyles[inlinePosProperty] = `${parseInt(String(left - handleSize - 1), 10)}px`;
433
435
  topHitAreaStyles.top = `${parseInt(String(top - hitAreaSize / 4 * 3), 10)}px`;
@@ -935,42 +937,33 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
935
937
  return anchorTop + geometryReader.outerHeight(TD) + cornerHalfHeight >= geometryReader.innerHeight(trimmingContainer);
936
938
  }
937
939
  /**
938
- * Show border around one or many cells.
939
- *
940
- * The fill handle is normally centered on the selection's bottom-end corner, so half of it hangs
941
- * past that corner. Where that overhang cannot survive — a container edge, or a frozen pane that
942
- * clips or covers it — the handle is pulled back inside instead, and `wtCornerInlineEndEdge` /
943
- * `wtCornerBlockEndEdge` pull its hit area along. See {@link Border#isCornerLiftedAtInlineEnd} and
944
- * {@link Border#isCornerLiftedAtBlockEnd} for which edges those are.
940
+ * Show border around one or many cells: {@link Border#measure} first, then {@link Border#paint}.
941
+ * A pass over many borders measures all of them before painting any (see `SelectionManager#render`).
945
942
  *
946
943
  * @param {Array} corners The corner coordinates.
947
944
  */ appear(corners) {
948
945
  if (this.disabled) {
949
946
  return;
950
947
  }
951
- // A selection flush against a frozen-pane boundary has its top/inline-start edge rendered by the
952
- // master on the freeze line, where the frozen overlay occludes it. Re-draw it inside the frozen
953
- // overlay so it stays visible; no-op unless `fixedRowsTop`/`fixedColumnsStart` is used.
954
- //
955
- // When it draws, we return early and intentionally skip the rest of `appear` (corner/fill handle,
956
- // the other edges): in these overlays the selection's cell isn't rendered here — only the seam
957
- // edge slice is — so there is nothing else to draw.
958
- if (this.drawFrozenBoundaryEdge(corners)) {
959
- return;
948
+ this.paint(corners, this.measure(corners));
949
+ }
950
+ /**
951
+ * Reads every piece of geometry {@link Border#paint} needs. It must not write to the DOM: a write
952
+ * between two geometry reads forces the browser to lay the table out again, and a pass over
953
+ * thousands of borders then costs one layout per border.
954
+ *
955
+ * @param {Array} corners The corner coordinates.
956
+ * @returns {BorderMeasurement|null} The measurement, or `null` when nothing is to be drawn.
957
+ */ measure(corners) {
958
+ if (this.disabled) {
959
+ return null;
960
960
  }
961
961
  let [fromRow, fromColumn, toRow, toColumn] = corners;
962
- // Capture the top-start corner before the clamping below mutates it — used to suppress the
963
- // master's boundary edge (so it isn't doubled by the frozen overlay's edge).
964
- const originalFromRow = fromRow;
965
- const originalFromColumn = fromColumn;
966
- const originalToRow = toRow;
967
- const originalToColumn = toColumn;
968
962
  // borders can not be rendered on headers so hide them
969
963
  if (fromRow < 0 && toRow < 0 || fromColumn < 0 && toColumn < 0) {
970
- this.disappear();
971
- return;
964
+ return null;
972
965
  }
973
- const { wtTable, rootDocument, rootWindow } = this.wot;
966
+ const { wtTable, rootWindow } = this.wot;
974
967
  const { geometryReader } = this.wot.domBindings;
975
968
  const isMultiple = fromRow !== toRow || fromColumn !== toColumn;
976
969
  const firstRenderedRow = wtTable.getFirstRenderedRow();
@@ -979,8 +972,7 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
979
972
  const lastRenderedColumn = wtTable.getLastRenderedColumn();
980
973
  if (firstRenderedColumn < 0 && lastRenderedColumn < 0 || firstRenderedRow < 0 && lastRenderedRow < 0) {
981
974
  // ...also when overlays have rendered only headers skip it
982
- this.disappear();
983
- return;
975
+ return null;
984
976
  }
985
977
  let fromTD;
986
978
  if (isMultiple) {
@@ -989,19 +981,16 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
989
981
  fromRow = Math.max(fromRow, firstRenderedRow);
990
982
  toRow = Math.min(toRow, lastRenderedRow);
991
983
  if (toColumn < fromColumn || toRow < fromRow) {
992
- this.disappear();
993
- return;
984
+ return null;
994
985
  }
995
986
  fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
996
987
  if (!(0, _element.isHTMLElement)(fromTD)) {
997
- this.disappear();
998
- return;
988
+ return null;
999
989
  }
1000
990
  } else {
1001
991
  fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
1002
992
  if (!(0, _element.isHTMLElement)(fromTD)) {
1003
- this.disappear();
1004
- return;
993
+ return null;
1005
994
  }
1006
995
  }
1007
996
  const toTD = isMultiple ? wtTable.getCell(this.wot.createCellCoords(toRow, toColumn)) : fromTD;
@@ -1058,6 +1047,56 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
1058
1047
  inlineStartPos += 1;
1059
1048
  width = width > 0 ? width - 1 : 0;
1060
1049
  }
1050
+ return {
1051
+ toRow,
1052
+ toColumn,
1053
+ toTDEl,
1054
+ toOffset,
1055
+ isRtl,
1056
+ top,
1057
+ inlineStartPos,
1058
+ width,
1059
+ height,
1060
+ // The mobile handles are clamped to the table size, which paint() must not read between writes.
1061
+ tableSize: (0, _browser.isMobileBrowser)() && this.wot.getSetting('isDataViewInstance') ? {
1062
+ width: wtTable.getWidth(),
1063
+ height: wtTable.getHeight()
1064
+ } : null
1065
+ };
1066
+ }
1067
+ /**
1068
+ * Writes the border from the measurement {@link Border#measure} took.
1069
+ *
1070
+ * The fill handle is normally centered on the selection's bottom-end corner, so half of it hangs
1071
+ * past that corner. Where that overhang cannot survive — a container edge, or a frozen pane that
1072
+ * clips or covers it — the handle is pulled back inside instead, and `wtCornerInlineEndEdge` /
1073
+ * `wtCornerBlockEndEdge` pull its hit area along. See {@link Border#isCornerLiftedAtInlineEnd} and
1074
+ * {@link Border#isCornerLiftedAtBlockEnd} for which edges those are.
1075
+ *
1076
+ * @param {Array} corners The corner coordinates.
1077
+ * @param {BorderMeasurement|null} measurement The measurement, or `null` to hide the border.
1078
+ */ paint(corners, measurement) {
1079
+ if (this.disabled) {
1080
+ return;
1081
+ }
1082
+ // A selection flush against a frozen-pane boundary has its top/inline-start edge rendered by the
1083
+ // master on the freeze line, where the frozen overlay occludes it. Re-draw it inside the frozen
1084
+ // overlay so it stays visible; no-op unless `fixedRowsTop`/`fixedColumnsStart` is used.
1085
+ //
1086
+ // When it draws, we return early and intentionally skip the rest: in these overlays the
1087
+ // selection's cell isn't rendered here, only the seam edge slice is.
1088
+ if (this.drawFrozenBoundaryEdge(corners)) {
1089
+ return;
1090
+ }
1091
+ if (!measurement) {
1092
+ this.disappear();
1093
+ return;
1094
+ }
1095
+ const { rootDocument, rootWindow, wtTable } = this.wot;
1096
+ const { toRow, toColumn, toTDEl, toOffset, isRtl, top, inlineStartPos, width, height, tableSize } = measurement;
1097
+ // The raw corners, before `measure()` clamped them to the rendered range: used to suppress the
1098
+ // master's boundary edge (so it isn't doubled by the frozen overlay's edge).
1099
+ const [originalFromRow, originalFromColumn, originalToRow, originalToColumn] = corners;
1061
1100
  const inlinePosProperty = isRtl ? 'right' : 'left';
1062
1101
  // Corner geometry is resolved per edge rather than from a single `settings.border.width` delta,
1063
1102
  // which misaligns edges whose own width differs from the border-object default - e.g. a cell
@@ -1176,7 +1215,7 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
1176
1215
  this.cornerStyle.display = 'block';
1177
1216
  }
1178
1217
  if ((0, _browser.isMobileBrowser)() && this.wot.getSetting('isDataViewInstance')) {
1179
- this.updateMultipleSelectionHandlesPosition(toRow, toColumn, top, inlineStartPos, width, height);
1218
+ this.updateMultipleSelectionHandlesPosition(toRow, toColumn, top, inlineStartPos, width, height, tableSize);
1180
1219
  }
1181
1220
  let adjustVisible = this.settings.border?.adjustHandlesVisible;
1182
1221
  adjustVisible = typeof adjustVisible === 'function' ? adjustVisible(this.settings.layerLevel) : adjustVisible;
@@ -409,15 +409,17 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
409
409
  * @param {number} left The left position of the handler.
410
410
  * @param {number} width The width of the handler.
411
411
  * @param {number} height The height of the handler.
412
- */ updateMultipleSelectionHandlesPosition(row, col, top, left, width, height) {
412
+ * @param {{width: number, height: number}|null} [tableSize] The table size `measure()` read, so the
413
+ * handles are positioned without a geometry read between style writes.
414
+ */ updateMultipleSelectionHandlesPosition(row, col, top, left, width, height, tableSize = null) {
413
415
  const isRtl = this.wot.wtSettings.getSetting('rtlMode');
414
416
  const inlinePosProperty = isRtl ? 'right' : 'left';
415
417
  const { top: topStyles, topHitArea: topHitAreaStyles, bottom: bottomStyles, bottomHitArea: bottomHitAreaStyles } = this.selectionHandles.styles;
416
418
  const handleBorderSize = parseInt(topStyles.borderWidth, 10);
417
419
  const handleSize = parseInt(topStyles.width, 10);
418
420
  const hitAreaSize = parseInt(topHitAreaStyles.width, 10);
419
- const totalTableWidth = this.wot.wtTable.getWidth();
420
- const totalTableHeight = this.wot.wtTable.getHeight();
421
+ const totalTableWidth = tableSize?.width ?? this.wot.wtTable.getWidth();
422
+ const totalTableHeight = tableSize?.height ?? this.wot.wtTable.getHeight();
421
423
  topStyles.top = `${parseInt(String(top - handleSize - 1), 10)}px`;
422
424
  topStyles[inlinePosProperty] = `${parseInt(String(left - handleSize - 1), 10)}px`;
423
425
  topHitAreaStyles.top = `${parseInt(String(top - hitAreaSize / 4 * 3), 10)}px`;
@@ -925,42 +927,33 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
925
927
  return anchorTop + geometryReader.outerHeight(TD) + cornerHalfHeight >= geometryReader.innerHeight(trimmingContainer);
926
928
  }
927
929
  /**
928
- * Show border around one or many cells.
929
- *
930
- * The fill handle is normally centered on the selection's bottom-end corner, so half of it hangs
931
- * past that corner. Where that overhang cannot survive — a container edge, or a frozen pane that
932
- * clips or covers it — the handle is pulled back inside instead, and `wtCornerInlineEndEdge` /
933
- * `wtCornerBlockEndEdge` pull its hit area along. See {@link Border#isCornerLiftedAtInlineEnd} and
934
- * {@link Border#isCornerLiftedAtBlockEnd} for which edges those are.
930
+ * Show border around one or many cells: {@link Border#measure} first, then {@link Border#paint}.
931
+ * A pass over many borders measures all of them before painting any (see `SelectionManager#render`).
935
932
  *
936
933
  * @param {Array} corners The corner coordinates.
937
934
  */ appear(corners) {
938
935
  if (this.disabled) {
939
936
  return;
940
937
  }
941
- // A selection flush against a frozen-pane boundary has its top/inline-start edge rendered by the
942
- // master on the freeze line, where the frozen overlay occludes it. Re-draw it inside the frozen
943
- // overlay so it stays visible; no-op unless `fixedRowsTop`/`fixedColumnsStart` is used.
944
- //
945
- // When it draws, we return early and intentionally skip the rest of `appear` (corner/fill handle,
946
- // the other edges): in these overlays the selection's cell isn't rendered here — only the seam
947
- // edge slice is — so there is nothing else to draw.
948
- if (this.drawFrozenBoundaryEdge(corners)) {
949
- return;
938
+ this.paint(corners, this.measure(corners));
939
+ }
940
+ /**
941
+ * Reads every piece of geometry {@link Border#paint} needs. It must not write to the DOM: a write
942
+ * between two geometry reads forces the browser to lay the table out again, and a pass over
943
+ * thousands of borders then costs one layout per border.
944
+ *
945
+ * @param {Array} corners The corner coordinates.
946
+ * @returns {BorderMeasurement|null} The measurement, or `null` when nothing is to be drawn.
947
+ */ measure(corners) {
948
+ if (this.disabled) {
949
+ return null;
950
950
  }
951
951
  let [fromRow, fromColumn, toRow, toColumn] = corners;
952
- // Capture the top-start corner before the clamping below mutates it — used to suppress the
953
- // master's boundary edge (so it isn't doubled by the frozen overlay's edge).
954
- const originalFromRow = fromRow;
955
- const originalFromColumn = fromColumn;
956
- const originalToRow = toRow;
957
- const originalToColumn = toColumn;
958
952
  // borders can not be rendered on headers so hide them
959
953
  if (fromRow < 0 && toRow < 0 || fromColumn < 0 && toColumn < 0) {
960
- this.disappear();
961
- return;
954
+ return null;
962
955
  }
963
- const { wtTable, rootDocument, rootWindow } = this.wot;
956
+ const { wtTable, rootWindow } = this.wot;
964
957
  const { geometryReader } = this.wot.domBindings;
965
958
  const isMultiple = fromRow !== toRow || fromColumn !== toColumn;
966
959
  const firstRenderedRow = wtTable.getFirstRenderedRow();
@@ -969,8 +962,7 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
969
962
  const lastRenderedColumn = wtTable.getLastRenderedColumn();
970
963
  if (firstRenderedColumn < 0 && lastRenderedColumn < 0 || firstRenderedRow < 0 && lastRenderedRow < 0) {
971
964
  // ...also when overlays have rendered only headers skip it
972
- this.disappear();
973
- return;
965
+ return null;
974
966
  }
975
967
  let fromTD;
976
968
  if (isMultiple) {
@@ -979,19 +971,16 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
979
971
  fromRow = Math.max(fromRow, firstRenderedRow);
980
972
  toRow = Math.min(toRow, lastRenderedRow);
981
973
  if (toColumn < fromColumn || toRow < fromRow) {
982
- this.disappear();
983
- return;
974
+ return null;
984
975
  }
985
976
  fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
986
977
  if (!isHTMLElement(fromTD)) {
987
- this.disappear();
988
- return;
978
+ return null;
989
979
  }
990
980
  } else {
991
981
  fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
992
982
  if (!isHTMLElement(fromTD)) {
993
- this.disappear();
994
- return;
983
+ return null;
995
984
  }
996
985
  }
997
986
  const toTD = isMultiple ? wtTable.getCell(this.wot.createCellCoords(toRow, toColumn)) : fromTD;
@@ -1048,6 +1037,56 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
1048
1037
  inlineStartPos += 1;
1049
1038
  width = width > 0 ? width - 1 : 0;
1050
1039
  }
1040
+ return {
1041
+ toRow,
1042
+ toColumn,
1043
+ toTDEl,
1044
+ toOffset,
1045
+ isRtl,
1046
+ top,
1047
+ inlineStartPos,
1048
+ width,
1049
+ height,
1050
+ // The mobile handles are clamped to the table size, which paint() must not read between writes.
1051
+ tableSize: isMobileBrowser() && this.wot.getSetting('isDataViewInstance') ? {
1052
+ width: wtTable.getWidth(),
1053
+ height: wtTable.getHeight()
1054
+ } : null
1055
+ };
1056
+ }
1057
+ /**
1058
+ * Writes the border from the measurement {@link Border#measure} took.
1059
+ *
1060
+ * The fill handle is normally centered on the selection's bottom-end corner, so half of it hangs
1061
+ * past that corner. Where that overhang cannot survive — a container edge, or a frozen pane that
1062
+ * clips or covers it — the handle is pulled back inside instead, and `wtCornerInlineEndEdge` /
1063
+ * `wtCornerBlockEndEdge` pull its hit area along. See {@link Border#isCornerLiftedAtInlineEnd} and
1064
+ * {@link Border#isCornerLiftedAtBlockEnd} for which edges those are.
1065
+ *
1066
+ * @param {Array} corners The corner coordinates.
1067
+ * @param {BorderMeasurement|null} measurement The measurement, or `null` to hide the border.
1068
+ */ paint(corners, measurement) {
1069
+ if (this.disabled) {
1070
+ return;
1071
+ }
1072
+ // A selection flush against a frozen-pane boundary has its top/inline-start edge rendered by the
1073
+ // master on the freeze line, where the frozen overlay occludes it. Re-draw it inside the frozen
1074
+ // overlay so it stays visible; no-op unless `fixedRowsTop`/`fixedColumnsStart` is used.
1075
+ //
1076
+ // When it draws, we return early and intentionally skip the rest: in these overlays the
1077
+ // selection's cell isn't rendered here, only the seam edge slice is.
1078
+ if (this.drawFrozenBoundaryEdge(corners)) {
1079
+ return;
1080
+ }
1081
+ if (!measurement) {
1082
+ this.disappear();
1083
+ return;
1084
+ }
1085
+ const { rootDocument, rootWindow, wtTable } = this.wot;
1086
+ const { toRow, toColumn, toTDEl, toOffset, isRtl, top, inlineStartPos, width, height, tableSize } = measurement;
1087
+ // The raw corners, before `measure()` clamped them to the rendered range: used to suppress the
1088
+ // master's boundary edge (so it isn't doubled by the frozen overlay's edge).
1089
+ const [originalFromRow, originalFromColumn, originalToRow, originalToColumn] = corners;
1051
1090
  const inlinePosProperty = isRtl ? 'right' : 'left';
1052
1091
  // Corner geometry is resolved per edge rather than from a single `settings.border.width` delta,
1053
1092
  // which misaligns edges whose own width differs from the border-object default - e.g. a cell
@@ -1166,7 +1205,7 @@ const BORDER_STYLE_HORIZONTAL_SUFFIX = '-horizontal';
1166
1205
  this.cornerStyle.display = 'block';
1167
1206
  }
1168
1207
  if (isMobileBrowser() && this.wot.getSetting('isDataViewInstance')) {
1169
- this.updateMultipleSelectionHandlesPosition(toRow, toColumn, top, inlineStartPos, width, height);
1208
+ this.updateMultipleSelectionHandlesPosition(toRow, toColumn, top, inlineStartPos, width, height, tableSize);
1170
1209
  }
1171
1210
  let adjustVisible = this.settings.border?.adjustHandlesVisible;
1172
1211
  adjustVisible = typeof adjustVisible === 'function' ? adjustVisible(this.settings.layerLevel) : adjustVisible;
@@ -265,6 +265,7 @@ class SelectionManager {
265
265
  const selections = Array.from(_class_private_field_get(this, _selections));
266
266
  const classNamesMap = new Map();
267
267
  const headerAttributesMap = new Map();
268
+ const toDraw = [];
268
269
  for(let i = 0; i < selections.length; i++){
269
270
  const selection = selections[i];
270
271
  const { className, headerAttributes, createLayers, selectionType } = selection.settings;
@@ -273,11 +274,11 @@ class SelectionManager {
273
274
  selection.addLocalHook('destroy', ()=>this.destroyBorders(selection));
274
275
  }
275
276
  // Virtualize custom borders. A per-cell custom-border selection outside this overlay's rendered
276
- // range draws nothing anyway - `appear()` early-outs once `getCell()` reports the cell as not
277
- // rendered. Skipping it here (without calling `getBorderInstance`) means its Border DOM is never
278
- // created while off-screen, which is what lets grids with very many bordered cells scale: only
279
- // the visible borders get DOM and layout work, mirroring cell virtualization. The visual result
280
- // is identical to letting `appear()` early-out, just without the O(all-borders) DOM.
277
+ // range draws nothing anyway - `measure()` finds nothing to draw once `getCell()` reports the cell
278
+ // as not rendered. Skipping it here (without calling `getBorderInstance`) means its Border DOM is
279
+ // never created while off-screen, which is what lets grids with very many bordered cells scale:
280
+ // only the visible borders get DOM and layout work, mirroring cell virtualization. The visual
281
+ // result is identical to letting the border hide itself, just without the O(all-borders) DOM.
281
282
  if (selectionType === _constants.CUSTOM_SELECTION_TYPE && _class_private_method_get(this, _isCustomSelectionOffscreen, isCustomSelectionOffscreen).call(this, selection)) {
282
283
  _class_private_field_get(this, _selectionBorders).get(selection)?.get(_class_private_field_get(this, _activeOverlaysWot))?.disappear();
283
284
  continue; // eslint-disable-line no-continue
@@ -329,8 +330,17 @@ class SelectionManager {
329
330
  _class_private_method_get(this, _markFrozenBottomRowSeamHeader, markFrozenBottomRowSeamHeader).call(this, corners, className, classNamesMap);
330
331
  }
331
332
  _class_private_field_get(this, _activeOverlaysWot).getSetting('onBeforeDrawBorders', corners, selectionType);
332
- borderInstance?.appear(corners);
333
+ if (borderInstance) {
334
+ toDraw.push([
335
+ borderInstance,
336
+ corners
337
+ ]);
338
+ }
333
339
  }
340
+ // Measure every border before painting any: a style write between two geometry reads makes the
341
+ // browser lay the table out again, which cost one layout per visible border.
342
+ const measurements = toDraw.map(([border, corners])=>border.measure(corners));
343
+ toDraw.forEach(([border, corners], index)=>border.paint(corners, measurements[index]));
334
344
  classNamesMap.forEach((classNamesLayers, element)=>{
335
345
  const classNames = Array.from(classNamesLayers).map(([className, occurrenceCount])=>{
336
346
  if (occurrenceCount === 1) {
@@ -256,6 +256,7 @@ var /**
256
256
  const selections = Array.from(_class_private_field_get(this, _selections));
257
257
  const classNamesMap = new Map();
258
258
  const headerAttributesMap = new Map();
259
+ const toDraw = [];
259
260
  for(let i = 0; i < selections.length; i++){
260
261
  const selection = selections[i];
261
262
  const { className, headerAttributes, createLayers, selectionType } = selection.settings;
@@ -264,11 +265,11 @@ var /**
264
265
  selection.addLocalHook('destroy', ()=>this.destroyBorders(selection));
265
266
  }
266
267
  // Virtualize custom borders. A per-cell custom-border selection outside this overlay's rendered
267
- // range draws nothing anyway - `appear()` early-outs once `getCell()` reports the cell as not
268
- // rendered. Skipping it here (without calling `getBorderInstance`) means its Border DOM is never
269
- // created while off-screen, which is what lets grids with very many bordered cells scale: only
270
- // the visible borders get DOM and layout work, mirroring cell virtualization. The visual result
271
- // is identical to letting `appear()` early-out, just without the O(all-borders) DOM.
268
+ // range draws nothing anyway - `measure()` finds nothing to draw once `getCell()` reports the cell
269
+ // as not rendered. Skipping it here (without calling `getBorderInstance`) means its Border DOM is
270
+ // never created while off-screen, which is what lets grids with very many bordered cells scale:
271
+ // only the visible borders get DOM and layout work, mirroring cell virtualization. The visual
272
+ // result is identical to letting the border hide itself, just without the O(all-borders) DOM.
272
273
  if (selectionType === CUSTOM_SELECTION_TYPE && _class_private_method_get(this, _isCustomSelectionOffscreen, isCustomSelectionOffscreen).call(this, selection)) {
273
274
  _class_private_field_get(this, _selectionBorders).get(selection)?.get(_class_private_field_get(this, _activeOverlaysWot))?.disappear();
274
275
  continue; // eslint-disable-line no-continue
@@ -320,8 +321,17 @@ var /**
320
321
  _class_private_method_get(this, _markFrozenBottomRowSeamHeader, markFrozenBottomRowSeamHeader).call(this, corners, className, classNamesMap);
321
322
  }
322
323
  _class_private_field_get(this, _activeOverlaysWot).getSetting('onBeforeDrawBorders', corners, selectionType);
323
- borderInstance?.appear(corners);
324
+ if (borderInstance) {
325
+ toDraw.push([
326
+ borderInstance,
327
+ corners
328
+ ]);
329
+ }
324
330
  }
331
+ // Measure every border before painting any: a style write between two geometry reads makes the
332
+ // browser lay the table out again, which cost one layout per visible border.
333
+ const measurements = toDraw.map(([border, corners])=>border.measure(corners));
334
+ toDraw.forEach(([border, corners], index)=>border.paint(corners, measurements[index]));
325
335
  classNamesMap.forEach((classNamesLayers, element)=>{
326
336
  const classNames = Array.from(classNamesLayers).map(([className, occurrenceCount])=>{
327
337
  if (occurrenceCount === 1) {
package/CHANGELOG.md CHANGED
@@ -9,6 +9,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
10
  <!-- UNVERSIONED -->
11
11
 
12
+ ## [18.1.3] - 2026-11-20
13
+
14
+ ### Fixed
15
+ - Fixed slow scrolling of grids with many custom borders. [#13908](https://github.com/handsontable/handsontable/pull/13908)
16
+
12
17
  ## [18.1.2] - 2026-10-07
13
18
 
14
19
  ### Changed
package/base.js CHANGED
@@ -72,8 +72,8 @@ Handsontable.hooks = _hooks.Hooks.getSingleton();
72
72
  Handsontable.CellCoords = _src.CellCoords;
73
73
  Handsontable.CellRange = _src.CellRange;
74
74
  Handsontable.packageName = 'handsontable';
75
- Handsontable.buildDate = "07/10/2026 10:00:20";
76
- Handsontable.version = "18.1.2";
75
+ Handsontable.buildDate = "20/11/2026 09:39:21";
76
+ Handsontable.version = "18.1.3";
77
77
  Handsontable.languages = {
78
78
  dictionaryKeys: _registry.dictionaryKeys,
79
79
  getLanguageDictionary: _registry.getLanguageDictionary,
package/base.mjs CHANGED
@@ -43,8 +43,8 @@ Handsontable.hooks = Hooks.getSingleton();
43
43
  Handsontable.CellCoords = CellCoords;
44
44
  Handsontable.CellRange = CellRange;
45
45
  Handsontable.packageName = 'handsontable';
46
- Handsontable.buildDate = "07/10/2026 10:00:20";
47
- Handsontable.version = "18.1.2";
46
+ Handsontable.buildDate = "20/11/2026 09:39:21";
47
+ Handsontable.version = "18.1.3";
48
48
  Handsontable.languages = {
49
49
  dictionaryKeys,
50
50
  getLanguageDictionary,