mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(react): support navigating to same page and route updates in IonRouterOutlet, fixes #19891, #19892, #19986
This commit is contained in:
@ -69,12 +69,13 @@ const IonTabBarUnwrapped = /*@__PURE__*/(() => class extends React.Component<Pro
|
||||
}
|
||||
|
||||
private onTabButtonClick = (e: CustomEvent<{ href: string, selected: boolean, tab: string }>) => {
|
||||
const originalHref = this.state.tabs[e.detail.tab].originalHref;
|
||||
const currentHref = this.state.tabs[e.detail.tab].currentHref;
|
||||
if (this.state.activeTab === e.detail.tab) {
|
||||
const originalHref = this.state.tabs[e.detail.tab].originalHref;
|
||||
if (this.context.hasIonicRouter()) {
|
||||
this.context.tabNavigate(originalHref);
|
||||
if (originalHref === currentHref) {
|
||||
this.context.navigate(originalHref, 'none');
|
||||
} else {
|
||||
this.context.navigate(originalHref, 'back');
|
||||
this.context.navigate(originalHref, 'back', 'replace');
|
||||
}
|
||||
} else {
|
||||
if (this.props.onIonTabsWillChange) {
|
||||
@ -83,7 +84,7 @@ const IonTabBarUnwrapped = /*@__PURE__*/(() => class extends React.Component<Pro
|
||||
if (this.props.onIonTabsDidChange) {
|
||||
this.props.onIonTabsDidChange(new CustomEvent('ionTabDidChange', { detail: { tab: e.detail.tab } }));
|
||||
}
|
||||
this.context.navigate(this.state.tabs[e.detail.tab].currentHref, 'none');
|
||||
this.context.navigate(currentHref, 'none');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user