-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: tapping ion-back-button multiple times goes back multiple pages #18455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This double-tap on any button is an issue - causes multiple click events to run which causes issues. Perhaps an optional directive on the button (or a global sass variable) can be considered to allowing user to disable multiple event calls when button is double-tapped or rapid tapped? It's too tedious to implement stop guards on every button across an entire application when most buttons are single click actions. |
Double tap also causing #18104 |
Thanks for the issue! Does this only happen on specific devices or can it be reproduced in Chrome? |
I've been able to consistently reproduce on both Android and iOS devices. |
As far as I know only in iOS and Android. |
I met this issue for a long time , after the button clicked, the new page had added the css class BTW: It can reproduce in chrome @brandyscarney ,and no need to fast click the back button, just navigate through the page from a child page, it will show this issue. see screen below: |
@brandyscarney , I remove the code |
@brandyscarney , did you have a chance to look at this? |
Having the same issue as the original poster. |
Well, until this is properly addressed, I've built a custom back-button component that prevents it. In case it's useful for others, I'll share the code. Usage<app-back-button backHref="/home"></app-back-button> Source Codeimport { Component, Input } from '@angular/core';
import { NavController } from '@ionic/angular';
@Component({
selector: 'app-back-button',
templateUrl: './back-button.component.html'
})
export class BackButtonComponent {
@Input() backHref: string;
public buttonDisabled = false;
constructor(private navCtrl: NavController) {}
public async onClick (ev: Event) {
if (!this.backHref) return;
this.buttonDisabled = true;
await this.navCtrl.navigateBack([this.backHref]);
this.buttonDisabled = false;
ev.preventDefault();
}
} <ion-button [disabled]="buttonDisabled" (click)="onClick($event)">
<ion-icon name="chevron-back-outline"></ion-icon>
Back
</ion-button> |
Hi i'm a similar behavior, on my app when you double click this button de navigation it's trigger twice, even if you click it 3 or 4 times it navigates back the same times as clicked, and when you don't have pages on the stack the button disappears, i'm kind of worry because this endanger the integrity of my app :( this can be duplicated on iOS ,android and with ionic serve on Chrome. |
Hi @jdlopezq. I had the same situation, but I was able to fix the problem by building an identical custom component. See my comment above #18455 (comment) |
This problem also exists on ionic/react. I created a custom component similar to @drewctate to resolve this in the mean time. A few things to note:
|
@austin43 nice work! |
This problem still exists using Ionic/Angular. |
Would really appreciate a fix for this as it's definitely going to cause issues and is a pretty basic function of a mobile framework. |
the issue still exists, only happens when using native android |
I solved this issue by setting the defaultHref attribute of the ion-back-button to =" " then added a [disabled]="flag". this flag will disable and enable the button on a (click) function and Voilà backButtonDisabled = false; <ion-back-button backButtonPressed() { |
any updates? |
This issue still exists using Ionic 5.x |
@liamdebeasi - I have a sample repo that can repro this: https://github.com/kensodemann/demo-back-button Tab 1 has a child. Child one has a child. Double click back button on child two quickly. Note that child-one does not have its own back-button. |
Issue still exists on the latest ionic/angular. |
My temporary solution before it got fixed: Use
And in TS, use debounce for the navControl.back() method:
|
Hi everyone, We appreciate your patience as we work to resolve this issue. Can everyone try the following dev build and let me know if it resolves the issue? Angular
React
Vue
Stencil/Vanilla JavaScript
|
@liamdebeasi I just tried the angular version, it got fixed! 👍 |
Thanks for the issue. This has been resolved via #23526, and a fix will be available in an upcoming release of Ionic Framework. |
cc: @gshigeto |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version:
[x] 4.x
Current behavior:
If you tap twice at a back button (while there is no back button on the previous page), you go 2 pages back instead of one.
Expected behavior:
Go one page back
Steps to reproduce:
Create a app with 3 screens, navigate to the thirth screen, add a back button there (
<ion-back-button />
), double tap itRelated code:
Other information:
Ionic info:
The text was updated successfully, but these errors were encountered: