@xh/hoist 58.0.0 → 58.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.1 - 2023-07-13
4
+
5
+ ### 🐞 Bug Fixes
6
+
7
+ * Fixed bug where `TabContainerModel` with routing enabled would drop route params when navigating
8
+ between tabs.
9
+
3
10
  ## 58.0.0 - 2023-07-07
4
11
 
5
12
  ### 🎁 New Features
@@ -15,6 +15,7 @@ import {
15
15
  PersistOptions
16
16
  } from '@xh/hoist/core';
17
17
  import {action, observable, makeObservable} from '@xh/hoist/mobx';
18
+ import {wait} from '@xh/hoist/promise';
18
19
  import {ensureUniqueBy, throwIf} from '@xh/hoist/utils/js';
19
20
  import {isOmitted} from '@xh/hoist/utils/impl';
20
21
  import {find, isString, isUndefined, without, difference, findLast} from 'lodash';
@@ -151,6 +152,7 @@ export class TabContainerModel extends HoistModel {
151
152
  track: () => XH.routerState,
152
153
  run: this.syncWithRouter
153
154
  });
155
+ wait().then(() => this.syncWithRouter());
154
156
 
155
157
  this.forwardRouterToTab(this.activeTabId);
156
158
  } else if (persistWith) {
@@ -288,7 +290,8 @@ export class TabContainerModel extends HoistModel {
288
290
 
289
291
  const {route} = this;
290
292
  if (route) {
291
- XH.navigate(route + '.' + tab.id);
293
+ const {params} = XH.router.getState();
294
+ XH.navigate(route + '.' + tab.id, params);
292
295
  } else {
293
296
  this.setActiveTabIdInternal(tab.id);
294
297
  }
@@ -333,10 +336,11 @@ export class TabContainerModel extends HoistModel {
333
336
 
334
337
  private syncWithRouter() {
335
338
  const {tabs, route} = this,
336
- {router} = XH;
339
+ {router} = XH,
340
+ state = router.getState();
337
341
 
338
- if (router.isActive(route)) {
339
- const tab = tabs.find(t => router.isActive(route + '.' + t.id));
342
+ if (state && router.isActive(route)) {
343
+ const tab = tabs.find(t => router.isActive(route + '.' + t.id, state.params));
340
344
  if (tab && !tab.isActive && !tab.disabled) {
341
345
  this.setActiveTabIdInternal(tab.id);
342
346
  }
@@ -407,7 +407,7 @@ function calcClassFromColorSpec(v: number, colorSpec: ColorSpec | boolean): stri
407
407
  }
408
408
 
409
409
  function calcStyleFromColorSpec(v: number, colorSpec: ColorSpec | boolean): CSSProperties {
410
- if (!isFinite(v) || isBoolean(colorSpec)) return {};
410
+ if (!isFinite(v) || isBoolean(colorSpec) || !colorSpec) return {};
411
411
 
412
412
  const possibleStyles = v < 0 ? colorSpec.neg : v > 0 ? colorSpec.pos : colorSpec.neutral;
413
413
  return !isString(possibleStyles) ? possibleStyles : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "58.0.0",
3
+ "version": "58.0.1",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",