@ionic/react 8.7.14-nightly.20251216 → 8.7.14-nightly.20251217
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 +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1537,6 +1537,18 @@ class IonTabButton extends React.Component {
|
|
|
1537
1537
|
}
|
|
1538
1538
|
|
|
1539
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
|
+
};
|
|
1540
1552
|
class IonTabBarUnwrapped extends React.PureComponent {
|
|
1541
1553
|
constructor(props) {
|
|
1542
1554
|
super(props);
|
|
@@ -1569,7 +1581,7 @@ class IonTabBarUnwrapped extends React.PureComponent {
|
|
|
1569
1581
|
const tabKeys = Object.keys(tabs);
|
|
1570
1582
|
const activeTab = tabKeys.find((key) => {
|
|
1571
1583
|
const href = tabs[key].originalHref;
|
|
1572
|
-
return this.props.routeInfo.pathname
|
|
1584
|
+
return matchesTab(this.props.routeInfo.pathname, href);
|
|
1573
1585
|
});
|
|
1574
1586
|
if (activeTab) {
|
|
1575
1587
|
this.setState({
|
|
@@ -1602,7 +1614,7 @@ class IonTabBarUnwrapped extends React.PureComponent {
|
|
|
1602
1614
|
const tabKeys = Object.keys(state.tabs);
|
|
1603
1615
|
const activeTab = tabKeys.find((key) => {
|
|
1604
1616
|
const href = state.tabs[key].originalHref;
|
|
1605
|
-
return props.routeInfo.pathname
|
|
1617
|
+
return matchesTab(props.routeInfo.pathname, href);
|
|
1606
1618
|
});
|
|
1607
1619
|
// Check to see if the tab button href has changed, and if so, update it in the tabs state
|
|
1608
1620
|
React.Children.forEach(props.children, (child) => {
|