canvas-datagrid 0.3.15 → 0.3.17

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.
package/CHANGELOG.md CHANGED
@@ -7,7 +7,19 @@ All notable changes to this project will be documented in this file.
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
- ## 0.3.14 - 2021-10-20
10
+ ## 0.3.17 - 2021-11-18
11
+
12
+ ### Fixed
13
+
14
+ - Do not render row gaps when sorting (ndrsn, #391)
15
+
16
+ ## 0.3.16 - 2021-11-18
17
+
18
+ ### Fixed
19
+
20
+ - Fix string sort when value is null/undefined (faimaklg, #388)
21
+
22
+ ## 0.3.15 - 2021-11-18
11
23
 
12
24
  ### Fixed
13
25
 
@@ -2796,9 +2796,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
2796
2796
 
2797
2797
  self.ctx.restore(); // Gaps may occur in row numbers between consecutively rendered rows
2798
2798
  // when we are filtering. We draw attention to this by drawing a thick
2799
- // border overlapping the two consecutive row headers.
2799
+ // border overlapping the two consecutive row headers. If sorting, visible
2800
+ // row numbers stay the same (i.e. they don't correspond to the underlying
2801
+ // data's row number), so we do not show row gaps in that case.
2800
2802
 
2801
- if (isRowHeader && self.attributes.showRowNumbers && self.attributes.showRowNumberGaps) {
2803
+ var isSorting = self.orderings.columns && self.orderings.columns.length > 0;
2804
+
2805
+ if (isRowHeader && self.attributes.showRowNumbers && self.attributes.showRowNumberGaps && isSorting === false) {
2802
2806
  var previousRowNumber = self.getBoundRowIndexFromViewRowIndex(rowOrderIndex - 1);
2803
2807
  var hasRowGap = previousRowNumber !== undefined && cell.boundRowIndex > 0 && cell.boundRowIndex - previousRowNumber > 1;
2804
2808
 
@@ -8734,27 +8738,22 @@ __webpack_require__.r(__webpack_exports__);
8734
8738
  self.sorters.string = function (columnName, direction) {
8735
8739
  var asc = direction === 'asc';
8736
8740
  return function (a, b) {
8737
- if (a[columnName] === undefined || a[columnName] === null) {
8738
- return 1;
8739
- }
8740
-
8741
- if (b[columnName] === undefined || b[columnName] === null) {
8742
- return 0;
8743
- }
8741
+ var aValue = a[columnName] || '';
8742
+ var bValue = b[columnName] || '';
8744
8743
 
8745
8744
  if (asc) {
8746
- if (!a[columnName].localeCompare) {
8745
+ if (!aValue.localeCompare) {
8747
8746
  return 1;
8748
8747
  }
8749
8748
 
8750
- return a[columnName].localeCompare(b[columnName]);
8749
+ return aValue.localeCompare(bValue);
8751
8750
  }
8752
8751
 
8753
- if (!b[columnName].localeCompare) {
8752
+ if (!bValue.localeCompare) {
8754
8753
  return 1;
8755
8754
  }
8756
8755
 
8757
- return b[columnName].localeCompare(a[columnName]);
8756
+ return bValue.localeCompare(aValue);
8758
8757
  };
8759
8758
  };
8760
8759