Просмотр исходного кода

refactor(handsontable): recover some change

qinlaiqiao 5 лет назад
Родитель
Сommit
8463332466

+ 1 - 1
handsontable/handsontable.d.ts

@@ -38,7 +38,7 @@ declare namespace _Handsontable {
 
     destroy(): void;
 
-    destroyEditor(revertOriginal?: boolean, prepareEditorIfNeeded?: boolean, isOutClick? : boolean): void;
+    destroyEditor(revertOriginal?: boolean, prepareEditorIfNeeded?: boolean): void;
 
     emptySelectedCells(): void;
 

+ 1 - 1
handsontable/package.json

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

+ 4 - 6
handsontable/src/core.js

@@ -1240,10 +1240,9 @@ export default function Core(rootElement, userSettings, rootInstanceSymbol = fal
    * @function destroyEditor
    * @param {Boolean} [revertOriginal=false] If `true`, the previous value will be restored. Otherwise, the edited value will be saved.
    * @param {Boolean} [prepareEditorIfNeeded=true] If `true` the editor under the selected cell will be prepared to open.
-   * @param {Boolean} [isOutClick=false] 解决outsideClickDeselects为False时,切换tab导致表头行号等渲染出错问题,点击表格外部,并不需要重新刷新表格
    */
-  this.destroyEditor = function(revertOriginal = false, prepareEditorIfNeeded = true, isOutClick = false) {
-    instance._refreshBorders(revertOriginal, prepareEditorIfNeeded, isOutClick);
+  this.destroyEditor = function(revertOriginal = false, prepareEditorIfNeeded = true) {
+    instance._refreshBorders(revertOriginal, prepareEditorIfNeeded);
   };
 
   /**
@@ -3583,11 +3582,10 @@ export default function Core(rootElement, userSettings, rootInstanceSymbol = fal
    * @private
    * @param {Boolean} [revertOriginal=false] If `true`, the previous value will be restored. Otherwise, the edited value will be saved.
    * @param {Boolean} [prepareEditorIfNeeded=true] If `true` the editor under the selected cell will be prepared to open.
-   * @param {Boolean} [isOutClick=false] If `false` 重新刷新表格. If ture 说明是点击表格外不需要重新刷新
    */
-  this._refreshBorders = function(revertOriginal = false, prepareEditorIfNeeded = true, isOutClick = false) {
+  this._refreshBorders = function(revertOriginal = false, prepareEditorIfNeeded = true) {
     editorManager.destroyEditor(revertOriginal);
-    if (isOutClick === false) instance.view.render();
+    instance.view.render();
 
     if (prepareEditorIfNeeded && selection.isSelected()) {
       editorManager.prepareEditor();

+ 6 - 7
handsontable/src/plugins/contextMenu/menu.js

@@ -101,8 +101,6 @@ class Menu {
    */
   open() {
     this.runLocalHooks('beforeOpen');
-    // 2021-02-24  zhang createContainer里面先查找是否存在,有则返回。 如果不这样做的话,element-tabs 设置成lazzy后,后加载的页面会冲掉之前页面的右键菜单
-    this.container = this.createContainer(this.options.name);
     this.container.removeAttribute('style');
     this.container.style.display = 'block';
 
@@ -286,8 +284,8 @@ class Menu {
 
     // Don't close context menu if item is disabled or it has submenu
     if (selectedItem.disabled === true ||
-        (typeof selectedItem.disabled === 'function' && selectedItem.disabled.call(this.hot) === true) ||
-        selectedItem.submenu) {
+      (typeof selectedItem.disabled === 'function' && selectedItem.disabled.call(this.hot) === true) ||
+      selectedItem.submenu) {
       autoClose = false;
     }
 
@@ -564,7 +562,8 @@ class Menu {
    * @private
    */
   blockMainTableCallbacks() {
-    this._afterScrollCallback = function() {};
+    this._afterScrollCallback = function() {
+    };
     this.hot.addHook('afterScrollVertically', this._afterScrollCallback);
     this.hot.addHook('afterScrollHorizontally', this._afterScrollCallback);
   }
@@ -710,9 +709,9 @@ class Menu {
     if (this.options.standalone && this.hotMenu && !isChildOf(event.target, this.hotMenu.rootElement)) {
       this.close(true);
 
-    // Automatically close menu when clicked element is not belongs to menu or submenu (not necessarily to itself)
+      // Automatically close menu when clicked element is not belongs to menu or submenu (not necessarily to itself)
     } else if ((this.isAllSubMenusClosed() || this.isSubMenu()) &&
-        (!isChildOf(event.target, '.htMenu') && isChildOf(event.target, document))) {
+      (!isChildOf(event.target, '.htMenu') && isChildOf(event.target, document))) {
       this.close(true);
     }
   }

+ 1 - 1
handsontable/src/tableView.js

@@ -170,7 +170,7 @@ function TableView(instance) {
     if (outsideClickDeselects) {
       instance.deselectCell();
     } else {
-      instance.destroyEditor(false, false, true);
+      instance.destroyEditor(false, false);
       instance.unlisten();// 点击tab等其它handsontable外的元素时,handsontable要解除监听键盘等事件. handsontable只在mouseup事件通过isOutsideInput只针对input 等几个输入元素
     }
   });