Skip to content
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

feat: Preserve last visited tab #293

Merged
merged 3 commits into from
Sep 27, 2024

Conversation

gopikrishnan13
Copy link
Contributor

@gopikrishnan13 gopikrishnan13 commented Aug 9, 2024

  • Implemented functionality to store and retrieve the last visited tab index in localStorage.
  • The application now defaults to the last visited tab after a page refresh, rather than always returning to the Activity tab.
  • This ensures that users remain on the same tab they were on before refreshing the page, improving user experience.
Screencast.from.09-08-24.12.45.17.PM.IST.WEBM

Closes #192

@gopikrishnan13 gopikrishnan13 changed the title Preserve last visited tab feat:Preserve last visited tab Aug 9, 2024
@gopikrishnan13 gopikrishnan13 changed the title feat:Preserve last visited tab feat: Preserve last visited tab Aug 9, 2024
@shariquerik
Copy link
Member

@gopikrishnan13 This is not a correct way to fix this.
We should be able to change tabs via url
E.g /crm/leads/CRM-LEAD-2024-0001#activity_tab

And we can then store the last visited tab in local storage
So if url does not have #activity_tab in it then it will show last visited tab and if it has it then that tab will be loaded

@gopikrishnan13
Copy link
Contributor Author

Hi @shariquerik

I made some updates based on your feedback and implemented the feature in the suggested way. it works fine.

I wrote this code in Lead.vue
image

Here’s the output video for your review.

Screencast.from.20-09-24.02.27.01.PM.IST.webm

Can I continue with this and make a commit?

Let me know if you have any further suggestions!

@shariquerik
Copy link
Member

@gopikrishnan13 Yeah go ahead

@gopikrishnan13
Copy link
Contributor Author

@shariquerik I updated this PR, please check it now,

  • Finalized the implementation of useActiveTabManager for tab management.
  • Enhanced logic to retrieve and set the active tab from both the URL and local storage.
  • Set default behavior to the first tab if no valid active tab is found.
  • Streamlined code for better readability and maintainability.
Screencast.from.25-09-24.06.00.23.PM.IST.webm

@shariquerik shariquerik merged commit 454973c into frappe:develop Sep 27, 2024
1 check passed
@shariquerik
Copy link
Member

🎉 This PR is included in version 1.24.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@gopikrishnan13 gopikrishnan13 deleted the last_visited_tab branch September 27, 2024 17:20
@shariquerik
Copy link
Member

shariquerik commented Sep 28, 2024

@gopikrishnan13 There is one problem occurred after this.
When you are in Deal Page and when you go back using browsers back button it does not go back it just removes #activity hash from the url and then again when you go back it goes back
And when you go forward it goes to /deals/#activity and now you cannot go back it just lost history somehow

It is very irritating

Fixed: 2f58da9

@gopikrishnan13
Copy link
Contributor Author

@shariquerik I have another solution, I’ve tested it, and it works well. Instead of setting the hash directly, I replace the history state only the first time when setting the tab from local storage. This way, it doesn’t affect the browser history and this prevents adding extra history entries

Do you think this is a better solution?

image

image

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

Successfully merging this pull request may close these issues.

Last Visited Tab
2 participants