Skip to content

Commit 8469307

Browse files
fix(Tenant): fix tree not fully collapsed bug (#551)
1 parent ab21c37 commit 8469307

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ import './ObjectSummary.scss';
5858

5959
const b = cn('object-summary');
6060

61-
const getInitialIsSummaryCollapsed = () => {
62-
return Boolean(localStorage.getItem(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED));
63-
};
61+
const getTenantCommonInfoState = () => {
62+
const collapsed = Boolean(localStorage.getItem(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED));
6463

65-
const initialTenantCommonInfoState = {
66-
triggerExpand: false,
67-
triggerCollapse: false,
68-
collapsed: getInitialIsSummaryCollapsed(),
64+
return {
65+
triggerExpand: false,
66+
triggerCollapse: false,
67+
collapsed,
68+
};
6969
};
7070

7171
function prepareOlapTableSchema(tableSchema: TColumnTableDescription = {}) {
@@ -109,7 +109,8 @@ export function ObjectSummary({
109109
const dispatch = useDispatch();
110110
const [commonInfoVisibilityState, dispatchCommonInfoVisibilityState] = useReducer(
111111
paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED),
112-
initialTenantCommonInfoState,
112+
undefined,
113+
getTenantCommonInfoState,
113114
);
114115
const {
115116
data,

src/containers/Tenant/Tenant.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import './Tenant.scss';
2727

2828
const b = cn('tenant-page');
2929

30-
const getInitialIsSummaryCollapsed = () => {
31-
return Boolean(localStorage.getItem(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED));
32-
};
30+
const getTenantSummaryState = () => {
31+
const collapsed = Boolean(localStorage.getItem(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED));
3332

34-
const initialTenantSummaryState = {
35-
triggerExpand: false,
36-
triggerCollapse: false,
37-
collapsed: getInitialIsSummaryCollapsed(),
33+
return {
34+
triggerExpand: false,
35+
triggerCollapse: false,
36+
collapsed,
37+
};
3838
};
3939

4040
interface TenantProps {
@@ -45,7 +45,8 @@ interface TenantProps {
4545
function Tenant(props: TenantProps) {
4646
const [summaryVisibilityState, dispatchSummaryVisibilityAction] = useReducer(
4747
paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED),
48-
initialTenantSummaryState,
48+
undefined,
49+
getTenantSummaryState,
4950
);
5051

5152
const {currentSchemaPath, currentSchema: currentItem = {}} = useSelector(

0 commit comments

Comments
 (0)