Skip to content

Filtering not applied when coming from the home page with search params #64

@Ahmad-code077

Description

@Ahmad-code077

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

  1. Go to the home page.
  2. Click a link pointing to: /products?category=audio
  3. Observe that the products page does not apply audio filter.
  4. Manually click the filter for audio.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions