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

Home button should reset page #390

Closed
tmheunis opened this issue Oct 6, 2023 · 2 comments · Fixed by #394
Closed

Home button should reset page #390

tmheunis opened this issue Oct 6, 2023 · 2 comments · Fixed by #394

Comments

@tmheunis
Copy link
Contributor

tmheunis commented Oct 6, 2023

If I filter subdatasets by any means, and then I select the home button I would expect to reset the filtering options to default. Also, if I click the home button I would expect it to reset to the subdatasets tab, if I were originally on funding or content tabs.

@jsheunis
Copy link
Member

Note to self about the functionality:

Home button calls router.push(params) and when Vue Router realises that the user is trying to navigate to the same route that is currently active, it throws an error:

vue-router.3.5.3.min.js:11 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/dataset/e132ac40-30c5-457d-8c7c-0dcbdbb95d9a/2954f6f464927b1ffd37ea0af8c716abf40d273a".
    at wt (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/vue-router.3.5.3.min.js:11:16484)
    at _t.confirmTransition (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/vue-router.3.5.3.min.js:11:19437)
    at _t.transitionTo (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/vue-router.3.5.3.min.js:11:18762)
    at e.push (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/vue-router.3.5.3.min.js:11:23180)
    at https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/vue-router.3.5.3.min.js:11:26586
    at new Promise (<anonymous>)
    at Vt.push (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/vue-router.3.5.3.min.js:11:26549)
    at rawFile.onreadystatechange (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/app_router.js:19:20)
    at beforeEnter (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/app_router.js:35:15)
    at y (https://psychoinformatics-de.github.io/sfb1451-projects-catalog/assets/vue-router.3.5.3.min.js:11:20045)
wt @ vue-router.3.5.3.min.js:11
_t.confirmTransition @ vue-router.3.5.3.min.js:11
_t.transitionTo @ vue-router.3.5.3.min.js:11
e.push @ vue-router.3.5.3.min.js:11
(anonymous) @ vue-router.3.5.3.min.js:11
Vt.push @ vue-router.3.5.3.min.js:11
rawFile.onreadystatechange @ app_router.js:19
beforeEnter @ app_router.js:35
y @ vue-router.3.5.3.min.js:11
n @ vue-router.3.5.3.min.js:11
n @ vue-router.3.5.3.min.js:11
vt @ vue-router.3.5.3.min.js:11
_t.confirmTransition @ vue-router.3.5.3.min.js:11
_t.transitionTo @ vue-router.3.5.3.min.js:11
e.push @ vue-router.3.5.3.min.js:11
(anonymous) @ vue-router.3.5.3.min.js:11
Vt.push @ vue-router.3.5.3.min.js:11
gotoHome @ app_component_dataset.js:380
Be @ vue.2.6.14.min.js:6
n @ vue.2.6.14.min.js:6
Qr.o._wrapper @ vue.2.6.14.min.js:6

vue-router.3.5.3.min.js:11 Uncaught (in promise) Error: Navigation cancelled from "/dataset/e132ac40-30c5-457d-8c7c-0dcbdbb95d9a/2954f6f464927b1ffd37ea0af8c716abf40d273a" to "/" with a new navigation.
    at wt (vue-router.3.5.3.min.js:11:16484)
    at gt (vue-router.3.5.3.min.js:11:16348)
    at y (vue-router.3.5.3.min.js:11:20032)
    at n (vue-router.3.5.3.min.js:11:15936)
    at vue-router.3.5.3.min.js:11:15955
    at vue-router.3.5.3.min.js:11:20411
    at rawFile.onreadystatechange (app_router.js:26:13)
    at beforeEnter (app_router.js:35:15)
    at y (vue-router.3.5.3.min.js:11:20045)
    at n (vue-router.3.5.3.min.js:11:15936)

I think the code should catch this redundant navigation attempt and call the necessary functionality.

Also, any refactoring of routing code should take into account route.push() and/or route.replace() for tab navigation, see #391.

@jsheunis
Copy link
Member

The current idea is to run some logic in the goToHome() function on the dataset component, before navigation:

Current logic when pressing home button when located on any dataset page in a catalog:

If there is NO home page set:

  • if there is a tab name in the URL, navigate to current
  • else: don't navigate, only "reset"

If there IS a home page set:

  • if the current page IS the home page:
    • if there is a tab name in the URL, navigate to current
    • else: don't navigate, only "reset"
  • if the current page is NOT the home page, navigate to home

reset = clear filters and set tab index = 0

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

Successfully merging a pull request may close this issue.

2 participants