فهرست منبع

fix(handsontable): 人材机汇页面列宽拖动错位问题

zhangweicheng 4 سال پیش
والد
کامیت
14224ecc0b
2فایلهای تغییر یافته به همراه9 افزوده شده و 9 حذف شده
  1. 1 1
      handsontable/package.json
  2. 8 8
      handsontable/src/plugins/manualColumnResize/manualColumnResize.js

+ 1 - 1
handsontable/package.json

@@ -10,7 +10,7 @@
     "url": "https://github.com/handsontable/handsontable/issues"
     "url": "https://github.com/handsontable/handsontable/issues"
   },
   },
   "author": "Handsoncode <hello@handsontable.com>",
   "author": "Handsoncode <hello@handsontable.com>",
-  "version": "6.3.14",
+  "version": "6.3.15",
   "browser": "dist/handsontable.js",
   "browser": "dist/handsontable.js",
   "main": "commonjs/index.js",
   "main": "commonjs/index.js",
   "module": "es/index.js",
   "module": "es/index.js",

+ 8 - 8
handsontable/src/plugins/manualColumnResize/manualColumnResize.js

@@ -143,14 +143,14 @@ class ManualColumnResize extends BasePlugin {
     this.currentTH = TH;
     this.currentTH = TH;
     // getCoords returns CellCoords
     // getCoords returns CellCoords
     // const col = this.hot.view.wt.wtTable.getCoords(TH).col;
     // const col = this.hot.view.wt.wtTable.getCoords(TH).col;
-    // const col = this.hot.getColHeader().indexOf(TH.innerText);
-    let col = 0;
-    for (let i = 0; i < TH.parentNode.childNodes.length; i += 1) {
-      if (TH.parentNode.childNodes[i] === TH) col = i;
-    }
-
-    if (!TH.parentNode.childNodes[0].innerText.replace(/(\s| )/gi, '')) {
-      col -= 1;
+    const text = TH.innerText.replace('\n', '<br>');
+    let col = this.hot.getColHeader().indexOf(text);
+    // 如果这里调大说明存在列头一模一样的情况,这时就直接用 html element里的顺序来
+    if (this.hot.getSettings().viewportColumnRenderingOffset >= 20) {
+      col = TH.cellIndex;
+      if (!TH.parentNode.childNodes[0].innerText.replace(/(\s| )/gi, '')) {
+        col -= 1;
+      }
     }
     }
 
 
     const headerHeight = outerHeight(this.currentTH);
     const headerHeight = outerHeight(this.currentTH);