Quellcode durchsuchen

chore: change variable name

代强 vor 1 Jahr
Ursprung
Commit
1b5b6794ac

+ 12 - 12
content/show/collapsible/index-en-US.md

@@ -178,18 +178,18 @@ import { Collapsible, Button } from '@douyinfe/semi-ui';
 ## API reference
 
 | Properties | Instructions                                                                                               | type | Default | version |
-| --- |------------------------------------------------------------------------------------------------------------| --- |---------| --- |
-| className | Class name                                                                                                 | string | -       | 0.34.0 |
-| collapseHeight | Collapse height                                                                                            | number | 0       | 1.0.0 |
-| duration | Time of animation execution                                                                                | number | 250     | - |
-| isOpen | Toggle whether to expand the content area                                                                  | boolean | `false` | - |
-| keepDOM | Whether to keep the hidden panel in DOM tree, destroyed by default                                         | boolean | `false` | 0.25.0 |
-| lazyRender | Used with keepDOM, when true, the component will not be rendered when mounting                                         | boolean | `false` | 2.24 |
-| motion | Toggle whether to turn on animation                                                                        | Motion | `true`  | - |
-| onMotionEnd | Animation end callback                                                                                     | () => void | -       | - |
-| reCalcKey | When reCalcKey changes, the height of children will be reset. Used for optimize dynamic content rendering. | number \| string | -       | 1.5.0 |
-| style | Style object                                                                                               | CSSProperties | -       | 0.34.0 |
-| aria-controls | [aria-controls](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls)  | string | -       | 2.3.0|
+| --- |------------------------------------------------------------------------------------------------------------| --- |---------|---------|
+| className | Class name                                                                                                 | string | -       | 0.34.0  |
+| collapseHeight | Collapse height                                                                                            | number | 0       | 1.0.0   |
+| duration | Time of animation execution                                                                                | number | 250     | -       |
+| isOpen | Toggle whether to expand the content area                                                                  | boolean | `false` | -       |
+| keepDOM | Whether to keep the hidden panel in DOM tree, destroyed by default                                         | boolean | `false` | 0.25.0  |
+| lazyRender | Used with keepDOM, when true, the component will not be rendered when mounting                                         | boolean | `false` | 2.54    |
+| motion | Toggle whether to turn on animation                                                                        | Motion | `true`  | -       |
+| onMotionEnd | Animation end callback                                                                                     | () => void | -       | -       |
+| reCalcKey | When reCalcKey changes, the height of children will be reset. Used for optimize dynamic content rendering. | number \| string | -       | 1.5.0   |
+| style | Style object                                                                                               | CSSProperties | -       | 0.34.0  |
+| aria-controls | [aria-controls](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls)  | string | -       | 2.3.0   |
 
 ## Accessibility
 

+ 10 - 10
content/show/collapsible/index.md

@@ -208,20 +208,20 @@ import { Collapsible, Button } from '@douyinfe/semi-ui';
 
 ## API 参考
 
-| 属性 | 说明 | 类型 | 默认值     | 版本 |
-| -- | --- | --- |---------| --- |
+| 属性 | 说明 | 类型 | 默认值     | 版本     |
+| -- | --- | --- |---------|--------|
 | className | 类名 | string | -       | 0.34.0 |
-| collapseHeight | 折叠高度 | number | 0       | 1.0.0 |
-| duration | 动画执行的时间 | number | 250     | - |
+| collapseHeight | 折叠高度 | number | 0       | 1.0.0  |
+| duration | 动画执行的时间 | number | 250     | -      |
 | fade | 是否开启淡入淡出 | boolean | false   | 2.21.0 |
-| isOpen | 是否展开内容区域 | boolean | `false` | - |
+| isOpen | 是否展开内容区域 | boolean | `false` | -      |
 | keepDOM | 是否保留隐藏的面板 DOM 树,默认销毁 | boolean | `false` | 0.25.0 |
-| lazyRender | 配合 keepDOM 使用,为 true 时挂载时不会渲染组件 | boolean | `false` | 2.24 |
-| motion | 是否开启动画 | boolean | `true`  | - |
-| onMotionEnd | 动画结束的回调 | () => void | -       | - |
-| reCalcKey | 当 reCalcKey 改变时,将重新计算子节点的高度,用于优化动态渲染时的计算 | number \| string | -       | 1.5.0 |
+| lazyRender | 配合 keepDOM 使用,为 true 时挂载时不会渲染组件 | boolean | `false` | 2.25   |
+| motion | 是否开启动画 | boolean | `true`  | -      |
+| onMotionEnd | 动画结束的回调 | () => void | -       | -      |
+| reCalcKey | 当 reCalcKey 改变时,将重新计算子节点的高度,用于优化动态渲染时的计算 | number \| string | -       | 1.5.0  |
 | style | 样式 | CSSProperties | -       | 0.34.0 |
-| id | id | html id string type | -       | 2.3.0 |
+| id | id | html id string type | -       | 2.3.0  |
 ## Accessibility
 
 ### ARIA

+ 6 - 4
packages/semi-ui/collapsible/index.tsx

@@ -50,7 +50,7 @@ class Collapsible extends BaseComponent<CollapsibleProps, CollapsibleState> {
     public foundation: CollapsibleFoundation;
     private domRef = React.createRef<HTMLDivElement>();
     private resizeObserver: ResizeObserver | null;
-    private hasRendered: boolean = false;
+    private hasBeenRendered: boolean = false;
 
     constructor(props: CollapsibleProps) {
         super(props);
@@ -176,10 +176,12 @@ class Collapsible extends BaseComponent<CollapsibleProps, CollapsibleState> {
             [`${cssClasses.PREFIX}-transition`]: this.props.motion && this.state.isTransitioning
         }, this.props.className);
 
-        const shouldRender = (this.props.keepDOM && (this.props.lazyRender ? this.hasRendered : true)) || this.props.collapseHeight !== 0 || this.state.visible || this.props.isOpen;
+        const shouldRender = (this.props.keepDOM &&
+            (this.props.lazyRender ? this.hasBeenRendered : true)) ||
+            this.props.collapseHeight !== 0 || this.state.visible || this.props.isOpen;
 
-        if (shouldRender && !this.hasRendered) {
-            this.hasRendered = true;
+        if (shouldRender && !this.hasBeenRendered) {
+            this.hasBeenRendered = true;
         }