Comparing version 3.0.9 to 3.0.10
@@ -265,5 +265,8 @@ import React from 'react'; | ||
* update a tab with new TabData | ||
* @param id tab id to update | ||
* @param newTab new tab data, if newTab is null, it only changes the active tab of parent panel | ||
* @param makeActive whether to make the tab the active child of parent panel | ||
* @returns returns false if the tab is not found | ||
*/ | ||
updateTab(id: string, newTab: TabData): boolean; | ||
updateTab(id: string, newTab: TabData, makeActive: boolean): boolean; | ||
/** @ignore */ | ||
@@ -270,0 +273,0 @@ getTabCache(id: string, owner: any): TabPaneCache; |
@@ -119,3 +119,3 @@ import React, { CSSProperties } from "react"; | ||
/** @inheritDoc */ | ||
updateTab(id: string, newTab: TabData): boolean; | ||
updateTab(id: string, newTab: TabData, makeActive?: boolean): boolean; | ||
constructor(props: LayoutProps); | ||
@@ -122,0 +122,0 @@ /** @ignore */ |
@@ -241,3 +241,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
/** @inheritDoc */ | ||
updateTab(id, newTab) { | ||
updateTab(id, newTab, makeActive = true) { | ||
let tab = this.find(id, Algorithm.Filter.AnyTab); | ||
@@ -249,9 +249,16 @@ if (tab && !('tabs' in tab)) { | ||
let { loadTab } = this.props; | ||
if (loadTab && !('content' in newTab && 'title' in newTab)) { | ||
newTab = loadTab(newTab); | ||
let layout = this.getLayout(); | ||
let activeId = panelData.activeId; | ||
if (newTab) { | ||
if (loadTab && !('content' in newTab && 'title' in newTab)) { | ||
newTab = loadTab(newTab); | ||
} | ||
layout = Algorithm.removeFromLayout(layout, tab); // remove old tab | ||
panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during removeTab | ||
layout = Algorithm.addTabToPanel(layout, newTab, panelData, idx); // add new tab | ||
panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during addTabToPanel | ||
} | ||
let layout = this.getLayout(); | ||
layout = Algorithm.removeFromLayout(layout, tab); // remove old tab | ||
panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during removeTab | ||
layout = Algorithm.addTabToPanel(layout, newTab, panelData, idx); // add new tab | ||
if (!makeActive) { | ||
panelData.activeId = activeId; | ||
} | ||
layout = Algorithm.fixLayoutData(layout); | ||
@@ -258,0 +265,0 @@ this.changeLayout(layout, newTab.id, 'update'); |
# History | ||
---- | ||
## 3.0.10 / 2021-04-11 | ||
- make it possible for Docklayout.updateTab to update tab without changing activeId | ||
## 3.0.8 / 2021-03-10 | ||
@@ -5,0 +8,0 @@ - when controlled layout is used and onLayoutChange callback doesn't set new layout prop, there should be a forceUpdate() so the original layout prop is re-rendered |
@@ -265,5 +265,8 @@ import React from 'react'; | ||
* update a tab with new TabData | ||
* @param id tab id to update | ||
* @param newTab new tab data, if newTab is null, it only changes the active tab of parent panel | ||
* @param makeActive whether to make the tab the active child of parent panel | ||
* @returns returns false if the tab is not found | ||
*/ | ||
updateTab(id: string, newTab: TabData): boolean; | ||
updateTab(id: string, newTab: TabData, makeActive: boolean): boolean; | ||
/** @ignore */ | ||
@@ -270,0 +273,0 @@ getTabCache(id: string, owner: any): TabPaneCache; |
@@ -119,3 +119,3 @@ import React, { CSSProperties } from "react"; | ||
/** @inheritDoc */ | ||
updateTab(id: string, newTab: TabData): boolean; | ||
updateTab(id: string, newTab: TabData, makeActive?: boolean): boolean; | ||
constructor(props: LayoutProps); | ||
@@ -122,0 +122,0 @@ /** @ignore */ |
@@ -266,3 +266,3 @@ "use strict"; | ||
/** @inheritDoc */ | ||
updateTab(id, newTab) { | ||
updateTab(id, newTab, makeActive = true) { | ||
let tab = this.find(id, Algorithm.Filter.AnyTab); | ||
@@ -274,9 +274,16 @@ if (tab && !('tabs' in tab)) { | ||
let { loadTab } = this.props; | ||
if (loadTab && !('content' in newTab && 'title' in newTab)) { | ||
newTab = loadTab(newTab); | ||
let layout = this.getLayout(); | ||
let activeId = panelData.activeId; | ||
if (newTab) { | ||
if (loadTab && !('content' in newTab && 'title' in newTab)) { | ||
newTab = loadTab(newTab); | ||
} | ||
layout = Algorithm.removeFromLayout(layout, tab); // remove old tab | ||
panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during removeTab | ||
layout = Algorithm.addTabToPanel(layout, newTab, panelData, idx); // add new tab | ||
panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during addTabToPanel | ||
} | ||
let layout = this.getLayout(); | ||
layout = Algorithm.removeFromLayout(layout, tab); // remove old tab | ||
panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during removeTab | ||
layout = Algorithm.addTabToPanel(layout, newTab, panelData, idx); // add new tab | ||
if (!makeActive) { | ||
panelData.activeId = activeId; | ||
} | ||
layout = Algorithm.fixLayoutData(layout); | ||
@@ -283,0 +290,0 @@ this.changeLayout(layout, newTab.id, 'update'); |
{ | ||
"name": "rc-dock", | ||
"version": "3.0.9", | ||
"version": "3.0.10", | ||
"description": "dock layout for react component", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -332,5 +332,8 @@ import React from 'react'; | ||
* update a tab with new TabData | ||
* @param id tab id to update | ||
* @param newTab new tab data, if newTab is null, it only changes the active tab of parent panel | ||
* @param makeActive whether to make the tab the active child of parent panel | ||
* @returns returns false if the tab is not found | ||
*/ | ||
updateTab(id: string, newTab: TabData): boolean; | ||
updateTab(id: string, newTab: TabData, makeActive: boolean): boolean; | ||
@@ -337,0 +340,0 @@ /** @ignore */ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
778750
13433