Describe the bug
When navigating to the Products page from the home page with a search parameter (for example: /products?category=audio), the filter state does not update correctly.
Expected behavior
The products page should read the URL query parameters and update the filter state based on them. For example, if ?category=audio is present, the audio filter should be selected and the product list updated.
Current behavior
- Visiting the link with a query param (e.g.
?category=audio) does not update the filter state.
- The filter UI still shows "all" until a manual filter selection is made.
- Reloading the page keeps the same URL, but filter still remains "all" until manually clicked.
Steps to reproduce
- Go to the home page.
- Click a link pointing to:
/products?category=audio
- Observe that the products page does not apply audio filter.
- Manually click the filter for audio.
- Filter applies correctly.
Expected fix
- Read the query parameters in the Products page component.
- Update the filter state on initial render using the query params.
- Update the UI filter selection accordingly.
- Apply the correct filtered results.
Additional context
Seems like the filter state is only updated on user click, not on initial load when a query param exists.
Describe the bug
When navigating to the Products page from the home page with a search parameter (for example:
/products?category=audio), the filter state does not update correctly.Expected behavior
The products page should read the URL query parameters and update the filter state based on them. For example, if
?category=audiois present, the audio filter should be selected and the product list updated.Current behavior
?category=audio) does not update the filter state.Steps to reproduce
/products?category=audioExpected fix
Additional context
Seems like the filter state is only updated on user click, not on initial load when a query param exists.