@ionic/react 8.7.13-dev.11765472680.117902a6 → 8.7.13-dev.11765486444.14025098

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/dist/index.js CHANGED
@@ -1331,10 +1331,10 @@ class OutletPageManager extends React.Component {
1331
1331
  this.ionLifeCycleContext.ionViewDidLeave();
1332
1332
  }
1333
1333
  render() {
1334
- const { StackManager, children, routeInfo, id, ...props } = this.props;
1334
+ const { StackManager, children, routeInfo, ...props } = this.props;
1335
1335
  return (jsx(IonLifeCycleContext.Consumer, { children: (context) => {
1336
1336
  this.ionLifeCycleContext = context;
1337
- return (jsx(StackManager, { routeInfo: routeInfo, id: id, children: jsx(IonRouterOutletInner, { setRef: (val) => (this.ionRouterOutlet = val), id: id, ...props, children: children }) }));
1337
+ return (jsx(StackManager, { routeInfo: routeInfo, children: jsx(IonRouterOutletInner, { setRef: (val) => (this.ionRouterOutlet = val), ...props, children: children }) }));
1338
1338
  } }));
1339
1339
  }
1340
1340
  static get contextType() {
@@ -1345,13 +1345,11 @@ class OutletPageManager extends React.Component {
1345
1345
  class IonRouterOutletContainer extends React.Component {
1346
1346
  constructor(props) {
1347
1347
  super(props);
1348
- this.outletId = props.id ?? `routerOutlet-${generateId('routerOutlet')}`;
1349
1348
  }
1350
1349
  render() {
1351
1350
  const StackManager = this.context.getStackManager();
1352
1351
  const { children, forwardedRef, ...props } = this.props;
1353
- const outletId = props.id ?? this.outletId;
1354
- return this.context.hasIonicRouter() ? (props.ionPage ? (jsx(OutletPageManager, { StackManager: StackManager, routeInfo: this.context.routeInfo, ...props, children: children })) : (jsx(StackManager, { routeInfo: this.context.routeInfo, id: outletId, children: jsx(IonRouterOutletInner, { ...props, id: outletId, forwardedRef: forwardedRef, children: children }) }))) : (jsx(IonRouterOutletInner, { ref: forwardedRef, ...this.props, children: this.props.children }));
1352
+ return this.context.hasIonicRouter() ? (props.ionPage ? (jsx(OutletPageManager, { StackManager: StackManager, routeInfo: this.context.routeInfo, ...props, children: children })) : (jsx(StackManager, { routeInfo: this.context.routeInfo, children: jsx(IonRouterOutletInner, { ...props, forwardedRef: forwardedRef, children: children }) }))) : (jsx(IonRouterOutletInner, { ref: forwardedRef, ...this.props, children: this.props.children }));
1355
1353
  }
1356
1354
  static get contextType() {
1357
1355
  return NavContext;
@@ -1539,6 +1537,18 @@ class IonTabButton extends React.Component {
1539
1537
  }
1540
1538
 
1541
1539
  // TODO(FW-2959): types
1540
+ /**
1541
+ * Checks if pathname matches the tab's href using path segment matching.
1542
+ * Avoids false matches like /home2 matching /home by requiring exact match
1543
+ * or a path segment boundary (/).
1544
+ */
1545
+ const matchesTab = (pathname, href) => {
1546
+ if (href === undefined) {
1547
+ return false;
1548
+ }
1549
+ const normalizedHref = href.endsWith('/') && href !== '/' ? href.slice(0, -1) : href;
1550
+ return pathname === normalizedHref || pathname.startsWith(normalizedHref + '/');
1551
+ };
1542
1552
  class IonTabBarUnwrapped extends React.PureComponent {
1543
1553
  constructor(props) {
1544
1554
  super(props);
@@ -1571,7 +1581,7 @@ class IonTabBarUnwrapped extends React.PureComponent {
1571
1581
  const tabKeys = Object.keys(tabs);
1572
1582
  const activeTab = tabKeys.find((key) => {
1573
1583
  const href = tabs[key].originalHref;
1574
- return this.props.routeInfo.pathname.startsWith(href);
1584
+ return matchesTab(this.props.routeInfo.pathname, href);
1575
1585
  });
1576
1586
  if (activeTab) {
1577
1587
  this.setState({
@@ -1604,7 +1614,7 @@ class IonTabBarUnwrapped extends React.PureComponent {
1604
1614
  const tabKeys = Object.keys(state.tabs);
1605
1615
  const activeTab = tabKeys.find((key) => {
1606
1616
  const href = state.tabs[key].originalHref;
1607
- return props.routeInfo.pathname.startsWith(href);
1617
+ return matchesTab(props.routeInfo.pathname, href);
1608
1618
  });
1609
1619
  // Check to see if the tab button href has changed, and if so, update it in the tabs state
1610
1620
  React.Children.forEach(props.children, (child) => {
@@ -2230,7 +2240,6 @@ const RouteManagerContext = /*@__PURE__*/ React.createContext({
2230
2240
  findLeavingViewItemByRouteInfo: () => undefined,
2231
2241
  findViewItemByRouteInfo: () => undefined,
2232
2242
  getChildrenToRender: () => undefined,
2233
- getViewItemsForOutlet: () => [],
2234
2243
  goBack: () => undefined,
2235
2244
  unMountViewItem: () => undefined,
2236
2245
  });
@@ -2349,14 +2358,7 @@ class LocationHistory {
2349
2358
  _replace(routeInfo) {
2350
2359
  const routeInfos = this._getRouteInfosByKey(routeInfo.tab);
2351
2360
  routeInfos && routeInfos.pop();
2352
- // Get the current route that's being replaced
2353
- const currentRoute = this.locationHistory[this.locationHistory.length - 1];
2354
- // Only pop from global history if we're replacing in the same outlet context.
2355
- // Don't pop if we're entering a nested outlet (current route has no tab, new route has a tab)
2356
- const isEnteringNestedOutlet = currentRoute && !currentRoute.tab && !!routeInfo.tab;
2357
- if (!isEnteringNestedOutlet) {
2358
- this.locationHistory.pop();
2359
- }
2361
+ this.locationHistory.pop();
2360
2362
  this._add(routeInfo);
2361
2363
  }
2362
2364
  _clear() {