king
2021-04-16 d7534812c8199bf1e9faa0279b63e434737d6374
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)