Skip to content

fix(marketplace): prevent search tab switches from polluting browser history#36102

Merged
crazywoola merged 1 commit into
feat/marketplace-templatefrom
fix/marketplace-search-tab-history
May 13, 2026
Merged

fix(marketplace): prevent search tab switches from polluting browser history#36102
crazywoola merged 1 commit into
feat/marketplace-templatefrom
fix/marketplace-search-tab-history

Conversation

@Yawen-1010
Copy link
Copy Markdown

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

On the marketplace, pressing the browser back button from All Templates (/search/templates) landed users on All Plugins (/search/plugins) instead of returning to the page that opened search (e.g. /templates).

Root cause: useSearchTab().handleChange in web/app/components/plugins/marketplace/atoms.ts always called router.push when switching the search tab. Because /search/plugins, /search/templates, etc. are distinct paths, every in-page tab switch added a new history entry — so back had to traverse those entries before leaving the search context.

Fix: distinguish entry from in-page navigation.

  • When already on /search/*, switch tabs with router.replace — no extra history entry.
  • When entering search from elsewhere (e.g. clicking "View More" on /templates), keep router.push — the prior page stays in history so back works.

After this change:

  • /templates → search input → /search/all → click Templates tab → /search/templatesBack goes directly to /templates (previously required two back clicks).
  • Existing flows that enter search from outside (View More, search submit) are unaffected.

Screenshots

Before After
Back from /search/templates lands on /search/plugins Back from /search/templates returns to /templates

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Switching tabs inside the search results page (/search/[searchTab])
used router.push, so each tab click added a history entry. As a
result, pressing back on All Templates would land on All Plugins
instead of returning to the page that opened search.

Now handleChange uses router.replace when already on /search/*, and
router.push only when navigating into search from elsewhere (e.g.
View More on /templates or /plugins). Back from a search results page
goes directly to the page the user came from.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. javascript labels May 13, 2026
@github-actions github-actions Bot added the web This relates to changes on the web. label May 13, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 13, 2026
@crazywoola crazywoola merged commit f497009 into feat/marketplace-template May 13, 2026
2 checks passed
@crazywoola crazywoola deleted the fix/marketplace-search-tab-history branch May 13, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants