Skip to content

Commit fa326bf

Browse files
committed
make cached default to true, deprecate animated property
1 parent 759412e commit fa326bf

File tree

6 files changed

+16
-25
lines changed

6 files changed

+16
-25
lines changed

HISTORY.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
# History
2-
----
1+
## 4.0.0
2+
3+
- migrate to pnpm
4+
- migrate to @rc-component packages
5+
- deprecated animated property in Tab
6+
- make Tab cached property default to true
37

48
## 3.2.18 / 2023-06-08
59
- fix the issue that sometimes dock icons are shown and no UI response after switching tabs quickly

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-dock",
3-
"version": "4.0.0-alpha.1",
3+
"version": "4.0.0-alpha.2",
44
"description": "dock layout for react component",
55
"repository": {
66
"type": "git",
@@ -48,7 +48,7 @@
4848
"@types/react": "^18.3.20",
4949
"@types/react-dom": "^18.3.6",
5050
"@types/shelljs": "^0.8.11",
51-
"less": "^4.1.2",
51+
"less": "^4.2.0",
5252
"node-gyp": "^10.1.0",
5353
"prismjs": "^1.26.0",
5454
"react": "^18.3.1",

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DockData.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export interface TabGroup {
3737
* default false
3838
*/
3939
tabLocked?: boolean;
40+
4041
/**
42+
* @deprecated no longer supported
4143
* Whether to show animation effect when switch tabs.
42-
*
43-
* default true
4444
*/
4545
animated?: boolean;
4646

@@ -208,9 +208,8 @@ export interface TabData extends TabBase, DockDataBase {
208208

209209

210210
/**
211-
* - when value is true: content will always reuse the react component thus allows the component to keep its internal state
212-
* - when value is false: content will be destroyed when it's not visible, [[TabGroup.animated]] should be set to false, otherwise animation would show blank pages
213-
* - when value is undefined: content is rendered normally as react component
211+
* - when value is true (default): content will always reuse the react component thus allows the component to keep its internal state
212+
* - when value is false: content will be destroyed when it's not visible
214213
*/
215214
cached?: boolean;
216215
/**

src/DockTabPane.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export default class DockTabPane extends React.PureComponent<DockTabPaneProps, a
5151
style,
5252
id,
5353
active,
54-
animated,
5554
// destroyInactiveTabPane, // Not in @rc-component/tabs TabPaneProps
5655
tabKey,
5756
children,
@@ -61,13 +60,7 @@ export default class DockTabPane extends React.PureComponent<DockTabPaneProps, a
6160
} // Removed destroyInactiveTabPane check
6261
const mergedStyle: React.CSSProperties = {};
6362
if (!active) {
64-
if (animated) {
65-
mergedStyle.visibility = 'hidden';
66-
mergedStyle.height = 0;
67-
mergedStyle.overflowY = 'hidden';
68-
} else {
69-
mergedStyle.display = 'none';
70-
}
63+
mergedStyle.display = 'none';
7164
}
7265

7366

src/DockTabs.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class TabCache {
177177
// Store the tab label and content for use in items array
178178
this.tabLabel = tab;
179179
this.tabContent = content;
180-
this.cached = cached;
180+
this.cached = cached ?? true;
181181

182182
return null; // We don't return JSX here anymore
183183
}
@@ -334,10 +334,7 @@ export class DockTabs extends React.PureComponent<Props> {
334334
render(): React.ReactNode {
335335
let {group, tabs, activeId} = this.props.panelData;
336336
let tabGroup = this.context.getGroup(group);
337-
let {animated, moreIcon} = tabGroup;
338-
if (animated == null) {
339-
animated = true;
340-
}
337+
let {moreIcon} = tabGroup;
341338
if (!moreIcon) {
342339
moreIcon = "...";
343340
}
@@ -358,7 +355,6 @@ export class DockTabs extends React.PureComponent<Props> {
358355
cacheId={id}
359356
cached={tabCache.cached}
360357
active={isActive}
361-
animated={animated}
362358
prefixCls="dock"
363359
>
364360
{tabCache.tabContent}
@@ -373,7 +369,6 @@ export class DockTabs extends React.PureComponent<Props> {
373369
return (
374370
<Tabs prefixCls="dock"
375371
more={{icon: moreIcon}}
376-
animated={animated}
377372
renderTabBar={this.renderTabBar}
378373
activeKey={activeId}
379374
onChange={this.onTabChange}

0 commit comments

Comments
 (0)