@douyinfe/semi-ui 2.54.0 → 2.54.1

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.
@@ -65945,7 +65945,8 @@ class NavigationFoundation extends foundation {
65945
65945
  items: formattedItems
65946
65946
  };
65947
65947
  } else {
65948
- this._adapter.updateSelectedKeys(willSelectedKeys);
65948
+ // already include parentSelectKeys, set second parameter to false
65949
+ this._adapter.updateSelectedKeys(willSelectedKeys, false);
65949
65950
  this._adapter.setItemKeysMap(itemKeysMap);
65950
65951
  this._adapter.updateOpenKeys(willOpenKeys);
65951
65952
  this._adapter.updateItems(formattedItems);
@@ -67192,24 +67193,19 @@ class Nav extends BaseComponent {
67192
67193
  componentDidMount() {
67193
67194
  // override BaseComponent
67194
67195
  }
67195
- componentDidUpdate(prevProps, prevState) {
67196
+ componentDidUpdate(prevProps) {
67196
67197
  if (prevProps.items !== this.props.items || prevProps.children !== this.props.children) {
67197
67198
  this.foundation.init();
67198
67199
  } else {
67199
67200
  this.foundation.handleItemsChange(false);
67200
- const {
67201
- selectedKeys
67202
- } = this.state;
67203
67201
  if (this.props.selectedKeys && !isEqual_default()(prevProps.selectedKeys, this.props.selectedKeys)) {
67204
67202
  this.adapter.updateSelectedKeys(this.props.selectedKeys);
67203
+ const willOpenKeys = this.foundation.getWillOpenKeys(this.state.itemKeysMap);
67204
+ this.adapter.updateOpenKeys(willOpenKeys);
67205
67205
  }
67206
67206
  if (this.props.openKeys && !isEqual_default()(prevProps.openKeys, this.props.openKeys)) {
67207
67207
  this.adapter.updateOpenKeys(this.props.openKeys);
67208
67208
  }
67209
- if (!isEqual_default()(selectedKeys, prevState.selectedKeys)) {
67210
- const parentSelectKeys = this.foundation.selectLevelZeroParentKeys(null, ...selectedKeys);
67211
- this.adapter.addSelectedKeys(...parentSelectKeys);
67212
- }
67213
67209
  }
67214
67210
  }
67215
67211
  get adapter() {
@@ -67235,9 +67231,20 @@ class Nav extends BaseComponent {
67235
67231
  }),
67236
67232
  addSelectedKeys: createAddKeysFn(this, 'selectedKeys'),
67237
67233
  removeSelectedKeys: createRemoveKeysFn(this, 'selectedKeys'),
67238
- updateSelectedKeys: selectedKeys => this.setState({
67239
- selectedKeys: [...selectedKeys]
67240
- }),
67234
+ /**
67235
+ * when `includeParentKeys` is `true`, select a nested nav item will select parent nav sub
67236
+ */
67237
+ updateSelectedKeys: function (selectedKeys) {
67238
+ let includeParentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
67239
+ let willUpdateSelectedKeys = selectedKeys;
67240
+ if (includeParentKeys) {
67241
+ const parentSelectKeys = _this.foundation.selectLevelZeroParentKeys(null, selectedKeys);
67242
+ willUpdateSelectedKeys = Array.from(new Set(selectedKeys.concat(parentSelectKeys)));
67243
+ }
67244
+ _this.setState({
67245
+ selectedKeys: willUpdateSelectedKeys
67246
+ });
67247
+ },
67241
67248
  updateOpenKeys: openKeys => this.setState({
67242
67249
  openKeys: [...openKeys]
67243
67250
  }),