@iobroker/adapter-react-v5 6.0.16 → 6.0.17

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.
@@ -355,12 +355,11 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
355
355
  #private;
356
356
  private info;
357
357
  private localStorage;
358
- private lastSelectedItems;
359
358
  private lastAppliedFilter;
360
359
  private readonly tableRef;
361
360
  private readonly filterRefs;
362
361
  private pausedSubscribes;
363
- private selectedFound;
362
+ private selectFirst;
364
363
  private root;
365
364
  private readonly states;
366
365
  private subscribes;
@@ -2187,18 +2187,18 @@ class ObjectBrowserClass extends react_1.Component {
2187
2187
  this.localStorage.removeItem(`${this.props.dialogName || 'App'}.table`);
2188
2188
  this.forceUpdate();
2189
2189
  };
2190
- const lastSelectedItems = this.localStorage.getItem(`${props.dialogName || 'App'}.objectSelected`) || '[]';
2191
- try {
2192
- this.lastSelectedItems = JSON.parse(lastSelectedItems);
2193
- if (typeof this.lastSelectedItems !== 'object') {
2194
- this.lastSelectedItems = [this.lastSelectedItems];
2190
+ const lastSelectedItemStr = this.localStorage.getItem(`${props.dialogName || 'App'}.objectSelected`) || '';
2191
+ if (lastSelectedItemStr.startsWith('[')) {
2192
+ try {
2193
+ const lastSelectedItems = JSON.parse(lastSelectedItemStr);
2194
+ this.selectFirst = lastSelectedItems[0] || '';
2195
+ }
2196
+ catch (e) {
2197
+ // ignore
2195
2198
  }
2196
- // remove empty items
2197
- this.lastSelectedItems = this.lastSelectedItems.filter((id) => id);
2198
2199
  }
2199
- catch (e) {
2200
- // ignore
2201
- this.lastSelectedItems = [];
2200
+ else {
2201
+ this.selectFirst = lastSelectedItemStr;
2202
2202
  }
2203
2203
  let expanded;
2204
2204
  const expandedStr = this.localStorage.getItem(`${props.dialogName || 'App'}.objectExpanded`) || '[]';
@@ -2256,7 +2256,7 @@ class ObjectBrowserClass extends react_1.Component {
2256
2256
  selected = props.selected;
2257
2257
  }
2258
2258
  selected = selected.map(id => id.replace(/["']/g, '')).filter(id => id);
2259
- this.selectedFound = !selected.length && !this.lastSelectedItems.length;
2259
+ this.selectFirst = selected.length && selected[0] ? selected[0] : this.selectFirst;
2260
2260
  const columnsStr = this.localStorage.getItem(`${props.dialogName || 'App'}.columns`);
2261
2261
  let columns;
2262
2262
  try {
@@ -2588,19 +2588,19 @@ class ObjectBrowserClass extends react_1.Component {
2588
2588
  */
2589
2589
  onAfterSelect(isDouble) {
2590
2590
  var _b;
2591
- this.lastSelectedItems = [...this.state.selected];
2592
- if ((_b = this.state.selected) === null || _b === void 0 ? void 0 : _b.length) {
2593
- this.localStorage.setItem(`${this.props.dialogName || 'App'}.objectSelected`, JSON.stringify(this.lastSelectedItems));
2594
- if (this.lastSelectedItems.length === 1 && this.objects[this.lastSelectedItems[0]]) {
2595
- const name = this.lastSelectedItems.length === 1
2596
- ? Utils_1.default.getObjectName(this.objects, this.lastSelectedItems[0], null, { language: this.props.lang })
2597
- : '';
2598
- this.props.onSelect && this.props.onSelect(this.lastSelectedItems, name, isDouble);
2591
+ if (((_b = this.state.selected) === null || _b === void 0 ? void 0 : _b.length) && this.state.selected[0]) {
2592
+ this.localStorage.setItem(`${this.props.dialogName || 'App'}.objectSelected`, this.state.selected[0]);
2593
+ // remove a task to select the pre-selected item if now we want to see another object
2594
+ if (this.selectFirst && this.selectFirst !== this.state.selected[0]) {
2595
+ this.selectFirst = '';
2596
+ }
2597
+ if (this.state.selected.length === 1 && this.objects[this.state.selected[0]]) {
2598
+ const name = Utils_1.default.getObjectName(this.objects, this.state.selected[0], null, { language: this.props.lang });
2599
+ this.props.onSelect && this.props.onSelect(this.state.selected, name, isDouble);
2599
2600
  }
2600
2601
  }
2601
2602
  else {
2602
2603
  this.localStorage.removeItem(`${this.props.dialogName || 'App'}.objectSelected`);
2603
- this.selectedFound = true;
2604
2604
  if (this.state.selected.length) {
2605
2605
  this.setState({ selected: [] }, () => this.props.onSelect && this.props.onSelect([], ''));
2606
2606
  }
@@ -5040,22 +5040,18 @@ class ObjectBrowserClass extends react_1.Component {
5040
5040
  * Called when component is updated.
5041
5041
  */
5042
5042
  componentDidUpdate() {
5043
- var _b, _c, _d, _e, _f, _g;
5044
- if (!this.selectedFound && !((_b = this.state.selected) === null || _b === void 0 ? void 0 : _b.length) && !((_c = this.lastSelectedItems) === null || _c === void 0 ? void 0 : _c.length)) {
5045
- this.selectedFound = true;
5046
- }
5047
5043
  if (this.tableRef.current) {
5048
5044
  const scrollBarWidth = this.tableRef.current.offsetWidth - this.tableRef.current.clientWidth;
5049
5045
  if (this.state.scrollBarWidth !== scrollBarWidth) {
5050
5046
  setTimeout(() => this.setState({ scrollBarWidth }), 100);
5051
5047
  }
5052
- else if (!this.selectedFound &&
5053
- (((_d = this.state.selected) === null || _d === void 0 ? void 0 : _d[0]) || ((_e = this.lastSelectedItems) === null || _e === void 0 ? void 0 : _e[0]))) {
5054
- this.scrollToItem(((_f = this.state.selected) === null || _f === void 0 ? void 0 : _f[0]) || ((_g = this.lastSelectedItems) === null || _g === void 0 ? void 0 : _g[0]));
5048
+ else if (this.selectFirst) {
5049
+ this.scrollToItem(this.selectFirst);
5055
5050
  }
5056
5051
  }
5057
5052
  }
5058
5053
  scrollToItem(id) {
5054
+ this.selectFirst = '';
5059
5055
  const node = window.document.getElementById(id);
5060
5056
  node &&
5061
5057
  node.scrollIntoView({
@@ -5063,7 +5059,6 @@ class ObjectBrowserClass extends react_1.Component {
5063
5059
  block: 'center',
5064
5060
  inline: 'center',
5065
5061
  });
5066
- this.selectedFound = true;
5067
5062
  }
5068
5063
  renderCustomDialog() {
5069
5064
  if (this.state.customDialog && this.props.objectCustomDialog) {
package/README.md CHANGED
@@ -781,7 +781,7 @@ The best practice is to replace `padding` with `p` and `margin` with `m`, so you
781
781
  -->
782
782
 
783
783
  ## Changelog
784
- ### 6.0.16 (2024-07-14)
784
+ ### 6.0.17 (2024-07-14)
785
785
  * (bluefox) Allowed playing mp3 files in the file browser
786
786
  * (bluefox) Corrected jump by object selection
787
787
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/adapter-react-v5",
3
- "version": "6.0.16",
3
+ "version": "6.0.17",
4
4
  "description": "React classes to develop admin interfaces for ioBroker with react.",
5
5
  "author": {
6
6
  "name": "Denis Haev (bluefox)",