Skip to content

fix: prevent taxonomy directory tabs from being intercepted - #2975

Open
RabbiIslamRony wants to merge 2 commits into
sovware:developmentfrom
RabbiIslamRony:investigate-client-issue-3255
Open

fix: prevent taxonomy directory tabs from being intercepted#2975
RabbiIslamRony wants to merge 2 commits into
sovware:developmentfrom
RabbiIslamRony:investigate-client-issue-3255

Conversation

@RabbiIslamRony

Copy link
Copy Markdown
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

How to reproduce the issue or how to test the changes

Main issue

When a page contains a Directorist Search Form together with All Categories or All Locations, the search-form script globally intercepts every .directorist-type-nav__link click.

Those taxonomy directory tabs are outside .directorist-search-contents, but the handler calls preventDefault() before checking for a valid search-form parent. As a result, the active tab can change visually while the normal ?directory_type=<slug> navigation is blocked and the displayed categories or locations remain unchanged.

This change scopes the AJAX click handler to directory links inside .directorist-search-contents and verifies the parent before preventing navigation. All Categories and All Locations tabs can now follow their normal URL, while the Search Form directory switcher keeps its existing AJAX behavior.

Easy test cases

  1. All Categories
    • Enable Multi Directory and create two directory types with different categories.
    • Add [directorist_search_listing] and [directorist_all_categories] to the same page.
    • Click the other directory tab.
    • Expected: the URL changes to ?directory_type=<slug> and the categories update for that directory.
  2. All Locations
    • Add [directorist_search_listing] and [directorist_all_locations] to the same page.
    • Click the other directory tab.
    • Expected: the URL changes and the locations update for that directory.
  3. Search Form regression
    • Change the directory type inside the Search Form.
    • Expected: the atbdp_listing_types_form AJAX request still runs and the search fields update without a full-page navigation.

Validation

  • npm run build-legacy
  • Source and production bundle JavaScript syntax checks
  • Focused selector regression test covering inside/outside search-form links
  • git diff --check

Any linked issues

Fixes TeamSync #3255

Checklist

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 this pull request may close these issues.

1 participant