ydb-ui-components 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ### [1.2.3](https://github.com/ydb-platform/ydb-ui-components/compare/v1.2.2...v1.2.3) (2022-05-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **NavigationTree:** expand tree to initial active path ([6a84dfb](https://github.com/ydb-platform/ydb-ui-components/commit/6a84dfb8b89f8411bd5b11f7b18582ed547c6d0d))
9
+
3
10
  ### [1.2.2](https://github.com/ydb-platform/ydb-ui-components/compare/v1.2.1...v1.2.2) (2022-05-23)
4
11
 
5
12
 
@@ -28,7 +28,7 @@ function NavigationTree(_ref) {
28
28
  getActions,
29
29
  activePath,
30
30
  onActivePathUpdate,
31
- cache
31
+ cache = true
32
32
  } = _ref;
33
33
 
34
34
  const [state, dispatch] = _react.default.useReducer(_state.reducer, {
@@ -28,7 +28,7 @@ function NavigationTreeDirectory(_ref) {
28
28
  activePath,
29
29
  onItemActivate,
30
30
  getActions,
31
- cache = true
31
+ cache
32
32
  } = _ref;
33
33
  const nodeState = state[path];
34
34
 
@@ -48,6 +48,7 @@ function NavigationTreeDirectory(_ref) {
48
48
  type: _state.NavigationTreeActionType.FinishLoading,
49
49
  payload: {
50
50
  path,
51
+ activePath,
51
52
  data
52
53
  }
53
54
  });
@@ -73,10 +73,19 @@ function reducer() {
73
73
  });
74
74
 
75
75
  for (const item of action.payload.data) {
76
+ var _state$path$collapsed, _state$path;
77
+
76
78
  const path = `${action.payload.path}/${item.name}`;
77
79
  const name = item.name;
78
- const type = item.type;
80
+ const type = item.type; // expand the tree according to the active path
81
+ // prioritize the existing state to expand the tree only on first load
82
+
83
+ const {
84
+ activePath = ''
85
+ } = action.payload;
86
+ const collapsed = (_state$path$collapsed = (_state$path = state[path]) === null || _state$path === void 0 ? void 0 : _state$path.collapsed) !== null && _state$path$collapsed !== void 0 ? _state$path$collapsed : !activePath.startsWith(`${path}/`);
79
87
  newState[path] = _objectSpread(_objectSpread({}, getDefaultNodeState()), {}, {
88
+ collapsed,
80
89
  path,
81
90
  name,
82
91
  type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-ui-components",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",