handsontable 0.0.0-next-1af4e47-20241125 → 0.0.0-next-c3d40ad-20241127

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

@@ -1202,9 +1202,11 @@ class Selection {
1202
1202
  if (!this.isSelected()) {
1203
1203
  return;
1204
1204
  }
1205
- const focusHighlight = this.highlight.getFocus();
1206
1205
  const currentLayer = this.getLayerLevel();
1207
- focusHighlight.commit().syncWith(this.selectedRange.current());
1206
+ const cellRange = this.selectedRange.current();
1207
+ if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
1208
+ this.highlight.getFocus().commit().syncWith(cellRange);
1209
+ }
1208
1210
 
1209
1211
  // Rewriting rendered ranges going through all layers.
1210
1212
  for (let layerLevel = 0; layerLevel < this.selectedRange.size(); layerLevel += 1) {
package/tableView.js CHANGED
@@ -198,38 +198,43 @@ class TableView {
198
198
  * Scroll viewport to a cell.
199
199
  *
200
200
  * @param {CellCoords} coords Renderable cell coordinates.
201
- * @param {boolean} [snapToTop] If `true`, viewport is scrolled to show the cell on the top of the table.
202
- * @param {boolean} [snapToRight] If `true`, viewport is scrolled to show the cell on the right side of the table.
203
- * @param {boolean} [snapToBottom] If `true`, viewport is scrolled to show the cell on the bottom side of the table.
204
- * @param {boolean} [snapToLeft] If `true`, viewport is scrolled to show the cell on the left side of the table.
201
+ * @param {'auto' | 'start' | 'end'} [horizontalSnap] If `'start'`, viewport is scrolled to show
202
+ * the cell on the left of the table. If `'end'`, viewport is scrolled to show the cell on the right of
203
+ * the table. When `'auto'`, the viewport is scrolled only when the column is outside of the viewport.
204
+ * @param {'auto' | 'top' | 'bottom'} [verticalSnap] If `'top'`, viewport is scrolled to show
205
+ * the cell on the top of the table. If `'bottom'`, viewport is scrolled to show the cell on the bottom of
206
+ * the table. When `'auto'`, the viewport is scrolled only when the row is outside of the viewport.
205
207
  * @returns {boolean}
206
208
  */
207
- scrollViewport(coords, snapToTop, snapToRight, snapToBottom, snapToLeft) {
208
- return this._wt.scrollViewport(coords, snapToTop, snapToRight, snapToBottom, snapToLeft);
209
+ scrollViewport(coords, horizontalSnap, verticalSnap) {
210
+ return this._wt.scrollViewport(coords, horizontalSnap, verticalSnap);
209
211
  }
210
212
 
211
213
  /**
212
214
  * Scroll viewport to a column.
213
215
  *
214
216
  * @param {number} column Renderable column index.
215
- * @param {boolean} [snapToRight] If `true`, viewport is scrolled to show the cell on the right side of the table.
216
- * @param {boolean} [snapToLeft] If `true`, viewport is scrolled to show the cell on the left side of the table.
217
+ * @param {'auto' | 'start' | 'end'} [snap] If `'start'`, viewport is scrolled to show
218
+ * the cell on the left of the table. If `'end'`, viewport is scrolled to show the cell on the right of
219
+ * the table. When `'auto'`, the viewport is scrolled only when the column is outside of the viewport.
217
220
  * @returns {boolean}
218
221
  */
219
- scrollViewportHorizontally(column, snapToRight, snapToLeft) {
220
- return this._wt.scrollViewportHorizontally(column, snapToRight, snapToLeft);
222
+ scrollViewportHorizontally(column, snap) {
223
+ return this._wt.scrollViewportHorizontally(column, snap);
221
224
  }
222
225
 
223
226
  /**
224
227
  * Scroll viewport to a row.
225
228
  *
226
229
  * @param {number} row Renderable row index.
227
- * @param {boolean} [snapToTop] If `true`, viewport is scrolled to show the cell on the top of the table.
228
- * @param {boolean} [snapToBottom] If `true`, viewport is scrolled to show the cell on the bottom side of the table.
230
+ * @param {'auto' | 'top' | 'bottom'} [snap] If `'top'`, viewport is scrolled to show
231
+ * the cell on the top of the table. If `'bottom'`, viewport is scrolled to show the cell on
232
+ * the bottom of the table. When `'auto'`, the viewport is scrolled only when the row is outside of
233
+ * the viewport.
229
234
  * @returns {boolean}
230
235
  */
231
- scrollViewportVertically(row, snapToTop, snapToBottom) {
232
- return this._wt.scrollViewportVertically(row, snapToTop, snapToBottom);
236
+ scrollViewportVertically(row, snap) {
237
+ return this._wt.scrollViewportVertically(row, snap);
233
238
  }
234
239
 
235
240
  /**
@@ -820,7 +825,7 @@ class TableView {
820
825
  },
821
826
  beforeDraw: (force, skipRender) => this.beforeRender(force, skipRender),
822
827
  onDraw: force => this.afterRender(force),
823
- onBeforeViewportScrollVertically: renderableRow => {
828
+ onBeforeViewportScrollVertically: (renderableRow, snapping) => {
824
829
  const rowMapper = this.hot.rowIndexMapper;
825
830
  const areColumnHeadersSelected = renderableRow < 0;
826
831
  let visualRow = renderableRow;
@@ -832,14 +837,14 @@ class TableView {
832
837
  return renderableRow;
833
838
  }
834
839
  }
835
- visualRow = this.hot.runHooks('beforeViewportScrollVertically', visualRow);
840
+ visualRow = this.hot.runHooks('beforeViewportScrollVertically', visualRow, snapping);
836
841
  this.hot.runHooks('beforeViewportScroll');
837
842
  if (!areColumnHeadersSelected) {
838
843
  return rowMapper.getRenderableFromVisualIndex(visualRow);
839
844
  }
840
845
  return visualRow;
841
846
  },
842
- onBeforeViewportScrollHorizontally: renderableColumn => {
847
+ onBeforeViewportScrollHorizontally: (renderableColumn, snapping) => {
843
848
  const columnMapper = this.hot.columnIndexMapper;
844
849
  const areRowHeadersSelected = renderableColumn < 0;
845
850
  let visualColumn = renderableColumn;
@@ -851,7 +856,7 @@ class TableView {
851
856
  return renderableColumn;
852
857
  }
853
858
  }
854
- visualColumn = this.hot.runHooks('beforeViewportScrollHorizontally', visualColumn);
859
+ visualColumn = this.hot.runHooks('beforeViewportScrollHorizontally', visualColumn, snapping);
855
860
  this.hot.runHooks('beforeViewportScroll');
856
861
  if (!areRowHeadersSelected) {
857
862
  return columnMapper.getRenderableFromVisualIndex(visualColumn);
package/tableView.mjs CHANGED
@@ -194,38 +194,43 @@ class TableView {
194
194
  * Scroll viewport to a cell.
195
195
  *
196
196
  * @param {CellCoords} coords Renderable cell coordinates.
197
- * @param {boolean} [snapToTop] If `true`, viewport is scrolled to show the cell on the top of the table.
198
- * @param {boolean} [snapToRight] If `true`, viewport is scrolled to show the cell on the right side of the table.
199
- * @param {boolean} [snapToBottom] If `true`, viewport is scrolled to show the cell on the bottom side of the table.
200
- * @param {boolean} [snapToLeft] If `true`, viewport is scrolled to show the cell on the left side of the table.
197
+ * @param {'auto' | 'start' | 'end'} [horizontalSnap] If `'start'`, viewport is scrolled to show
198
+ * the cell on the left of the table. If `'end'`, viewport is scrolled to show the cell on the right of
199
+ * the table. When `'auto'`, the viewport is scrolled only when the column is outside of the viewport.
200
+ * @param {'auto' | 'top' | 'bottom'} [verticalSnap] If `'top'`, viewport is scrolled to show
201
+ * the cell on the top of the table. If `'bottom'`, viewport is scrolled to show the cell on the bottom of
202
+ * the table. When `'auto'`, the viewport is scrolled only when the row is outside of the viewport.
201
203
  * @returns {boolean}
202
204
  */
203
- scrollViewport(coords, snapToTop, snapToRight, snapToBottom, snapToLeft) {
204
- return this._wt.scrollViewport(coords, snapToTop, snapToRight, snapToBottom, snapToLeft);
205
+ scrollViewport(coords, horizontalSnap, verticalSnap) {
206
+ return this._wt.scrollViewport(coords, horizontalSnap, verticalSnap);
205
207
  }
206
208
 
207
209
  /**
208
210
  * Scroll viewport to a column.
209
211
  *
210
212
  * @param {number} column Renderable column index.
211
- * @param {boolean} [snapToRight] If `true`, viewport is scrolled to show the cell on the right side of the table.
212
- * @param {boolean} [snapToLeft] If `true`, viewport is scrolled to show the cell on the left side of the table.
213
+ * @param {'auto' | 'start' | 'end'} [snap] If `'start'`, viewport is scrolled to show
214
+ * the cell on the left of the table. If `'end'`, viewport is scrolled to show the cell on the right of
215
+ * the table. When `'auto'`, the viewport is scrolled only when the column is outside of the viewport.
213
216
  * @returns {boolean}
214
217
  */
215
- scrollViewportHorizontally(column, snapToRight, snapToLeft) {
216
- return this._wt.scrollViewportHorizontally(column, snapToRight, snapToLeft);
218
+ scrollViewportHorizontally(column, snap) {
219
+ return this._wt.scrollViewportHorizontally(column, snap);
217
220
  }
218
221
 
219
222
  /**
220
223
  * Scroll viewport to a row.
221
224
  *
222
225
  * @param {number} row Renderable row index.
223
- * @param {boolean} [snapToTop] If `true`, viewport is scrolled to show the cell on the top of the table.
224
- * @param {boolean} [snapToBottom] If `true`, viewport is scrolled to show the cell on the bottom side of the table.
226
+ * @param {'auto' | 'top' | 'bottom'} [snap] If `'top'`, viewport is scrolled to show
227
+ * the cell on the top of the table. If `'bottom'`, viewport is scrolled to show the cell on
228
+ * the bottom of the table. When `'auto'`, the viewport is scrolled only when the row is outside of
229
+ * the viewport.
225
230
  * @returns {boolean}
226
231
  */
227
- scrollViewportVertically(row, snapToTop, snapToBottom) {
228
- return this._wt.scrollViewportVertically(row, snapToTop, snapToBottom);
232
+ scrollViewportVertically(row, snap) {
233
+ return this._wt.scrollViewportVertically(row, snap);
229
234
  }
230
235
 
231
236
  /**
@@ -816,7 +821,7 @@ class TableView {
816
821
  },
817
822
  beforeDraw: (force, skipRender) => this.beforeRender(force, skipRender),
818
823
  onDraw: force => this.afterRender(force),
819
- onBeforeViewportScrollVertically: renderableRow => {
824
+ onBeforeViewportScrollVertically: (renderableRow, snapping) => {
820
825
  const rowMapper = this.hot.rowIndexMapper;
821
826
  const areColumnHeadersSelected = renderableRow < 0;
822
827
  let visualRow = renderableRow;
@@ -828,14 +833,14 @@ class TableView {
828
833
  return renderableRow;
829
834
  }
830
835
  }
831
- visualRow = this.hot.runHooks('beforeViewportScrollVertically', visualRow);
836
+ visualRow = this.hot.runHooks('beforeViewportScrollVertically', visualRow, snapping);
832
837
  this.hot.runHooks('beforeViewportScroll');
833
838
  if (!areColumnHeadersSelected) {
834
839
  return rowMapper.getRenderableFromVisualIndex(visualRow);
835
840
  }
836
841
  return visualRow;
837
842
  },
838
- onBeforeViewportScrollHorizontally: renderableColumn => {
843
+ onBeforeViewportScrollHorizontally: (renderableColumn, snapping) => {
839
844
  const columnMapper = this.hot.columnIndexMapper;
840
845
  const areRowHeadersSelected = renderableColumn < 0;
841
846
  let visualColumn = renderableColumn;
@@ -847,7 +852,7 @@ class TableView {
847
852
  return renderableColumn;
848
853
  }
849
854
  }
850
- visualColumn = this.hot.runHooks('beforeViewportScrollHorizontally', visualColumn);
855
+ visualColumn = this.hot.runHooks('beforeViewportScrollHorizontally', visualColumn, snapping);
851
856
  this.hot.runHooks('beforeViewportScroll');
852
857
  if (!areRowHeadersSelected) {
853
858
  return columnMapper.getRenderableFromVisualIndex(visualColumn);