QutEcoacoustics / workbench-client

workbench-client: a client side browser application for interacting with acoustic workbenches
Other
8 stars 1 forks source link

Strong route query params are retained from current view when clicking on library menu item #2028

Open hudson-newey opened 1 year ago

hudson-newey commented 1 year ago

Describe the bug All rotueParams are retained from the current view to the library page if the user clicks on the "Library" navbar menu item.

To Reproduce Steps to reproduce the behavior:

  1. Click on Projects
  2. Go to page 3 / (1,n]
  3. Click on a project listed on page 3
  4. Click the back button on your web browser
  5. Click on "Library" menu item in the top menu bar
  6. Observe that you are seeing results from page 3

OR using url bar navigation

  1. Navigate to https://ecosounds.org/projects?page=3
  2. Click on Library
  3. Observe that you are seeing results from page 3

OR Using project that doesn't have multiple pages

  1. Navigate to https://www.ecosounds.org/projects/1107?page=3
  2. Click on "Library"
  3. Observe that you are seeing results from page 3

Or Using a project that does have multiple pages

  1. Navigate to https://ecosounds.org/
  2. Click on Projects
  3. Click on "Tasmanian Wetlands" (https://www.ecosounds.org/projects/1084)
  4. Click on page 2
  5. Press the refresh button in your browser
  6. Click on Library
  7. Observe that you are on page 2 of the library

OR Using audio recording id

  1. Navigate to https://www.ecosounds.org/projects/1107/audio_recordings/579698
  2. Click on "Library"
  3. Observe that you are viewing the audio recording 579698 on the library page

Expected behavior When the user clicks on the Library navbar menu item, it should always act as if the user is going to the home page of the library view (the user should always see page 1, without any filters or selected audio recordings)

Additional Behavior: From looking through the code it seems to be related to library.module.ts#L11

hudson-newey commented 1 year ago

I have fixed the issue related to the library item by creating a new libraryNav route. This is similar to how the projects nav menu item works.

However, an alternative solution that I have thought of is "sanitizing" / cleaning all baw-primary-menu > baw-header, baw-header-dropdown input strong routes (Maybe using a directive?) so they have no context of the current view. This would be more "correct" if all nav bar items are supposed to act as a navigation to a completely new view / session.

I have chosen not to use this solution as I believe that menu items routes should follow the same format / conventions as other parts of the client, and should not have their own special rules associated, and that menu routes should instead be explicitly defined as not carrying component route information at the route level, not baw-primary-menu level. By explicitly defining no routeParams in the library nav menu item, I have also conserved the possibility of a future nav bar item that can navigate with knowledge of the current route / component.

I will be adding code comments to document this for future developers and will add tests asserting that this change does not get accidentally reverted in future revisions.