From d7534812c8199bf1e9faa0279b63e434737d6374 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 16 四月 2021 16:06:27 +0800
Subject: [PATCH] 2021-04-16

---
 src/menu/components/tabs/antv-tabs/dragabletabs.jsx |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/menu/components/tabs/antv-tabs/dragabletabs.jsx b/src/menu/components/tabs/antv-tabs/dragabletabs.jsx
index 74ef3ef..b2d7ef7 100644
--- a/src/menu/components/tabs/antv-tabs/dragabletabs.jsx
+++ b/src/menu/components/tabs/antv-tabs/dragabletabs.jsx
@@ -1,5 +1,6 @@
 import React, { Component } from 'react'
 import { Tabs } from 'antd'
+import { is, fromJS } from 'immutable'
 import { DndProvider, DragSource, DropTarget } from 'react-dnd'
 
 // Drag & Drop node
@@ -52,8 +53,6 @@
     const newOrder = this.state.order.slice()
     const { children } = this.props
 
-    if (dragKey === 'tool' || hoverKey === 'tool') return
-
     React.Children.forEach(children, c => {
       if (newOrder.indexOf(c.key) === -1) {
         newOrder.push(c.key)
@@ -65,12 +64,11 @@
 
     newOrder.splice(dragIndex, 1)
     newOrder.splice(hoverIndex, 0, dragKey)
-    let _order = newOrder.filter(item => item !== 'tool')
     
     this.setState({
-      order: [..._order, 'tool']
+      order: newOrder
     })
-    this.props.tabsMove(_order)
+    this.props.tabsMove(newOrder)
   }
 
   renderTabBar = (props, DefaultTabBar) => (
@@ -83,10 +81,16 @@
     </DefaultTabBar>
   )
 
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.state), fromJS(nextState)) ||
+      !is(fromJS(nextProps.children), fromJS(this.props.children)) ||
+      nextProps.tabPosition !== this.props.tabPosition ||
+      nextProps.type !== this.props.type
+  }
+
   render() {
     const { order } = this.state
     const { children } = this.props
-
     const tabs = []
     React.Children.forEach(children, c => {
       tabs.push(c)

--
Gitblit v1.8.0