Skip to content

remove an item from navigation history without clearing the whole history #1525

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

Closed
tsonevn opened this issue Sep 20, 2018 · 8 comments
Closed
Assignees

Comments

@tsonevn
Copy link
Contributor

tsonevn commented Sep 20, 2018

From @janossuta on September 20, 2018 9:1

Hi,

I would like to remove an item from navigation history.

I have a route like this

Homepage -> Comment list -> Add comment

After you add a comment it navigates back to Comment list
So the navigation history is this:
Homepage -> Comment list -> Add comment -> Comment list

What I want is to prevent navigation back from Comment list to Add comment when pressing the back button and jump to Homepage instead

Comment list -> (back button) skip Add comment -> Homepage

Here is a simple example:
https://play.nativescript.org/?template=play-ng&id=zhyj9e

Which platform(s) does your issue occur on?

Both

Copied from original issue: NativeScript/NativeScript#6285

@tsonevn
Copy link
Contributor Author

tsonevn commented Sep 20, 2018

Hi @janossuta,
Currently, there is no way to remove a Page from the navigation history in NativeScript Angular. Regarding your case, I would suggest creating a modal page, where you can display the content for the Add comment component. When the new comment is added, you can close the modal and display the Comment list component.
For more info, you can review the Modal page article from the documentation and the sample in the issue here.

@janossuta
Copy link

Hi @tsonevn,

Thank you! I'm going to use modal page then.

@janossuta
Copy link

Hi @tsonevn,

Thank you it is solved my problem.

But I have an other question regarding modal views. If I have multiple modal views which are not related together but from the same page I have to create a modal-root component for each new modals?

Comment list page -> Add comment modal
Comment list page -> Show comment picture modal

@tsonevn
Copy link
Contributor Author

tsonevn commented Sep 21, 2018

Hi @janossuta,
Yes, in the described above scenario, when you have multiple modal pages, which are not related, you should define modal-root for each of them. Keep in mind that the first described approach is used in the scenarios, when you would like to setup ActionBar inside the modal page or when you will make navigations inside the modal.

In case you need to display only a specific component as a modal, you can use the approach described in the example here in the article.

@tsonevn tsonevn closed this as completed Sep 21, 2018
@BosH9
Copy link

BosH9 commented Jul 25, 2021

Any solution without model based approach ?

@joshcomley
Copy link
Contributor

Is there any solution to this now with all the updates since?

@IMDaniyal
Copy link

Any update on this without using the modal approach yet?

@gayatri-kadam
Copy link

Any update here? I wish to clear only the previous item from the navigation history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants