Fix Integrations tab not reflecting active route#2901
Conversation
Console (appwrite/console)Project ID: Tip Roll back Sites deployments instantly by switching between versions |
Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
|
|
||
| function isTabSelected(key: string) { | ||
| return page.url.pathname.endsWith(`/${key}`); | ||
| return page.url.pathname.split('/').includes(key); |
There was a problem hiding this comment.
@copilot this is not the issue. The tab is incorrect even when I'm on /project-x-y/overview/api-keys
There was a problem hiding this comment.
You're right - the actual issue was that page.url.pathname accessed inside a function closure isn't reactive in Svelte 5 legacy mode. The reactive dependency needs to be directly in the template expression, which is the pattern used in account/header.svelte and auth/header.svelte.
Fixed in commit 010f2f8: isTabSelected now accepts pathname as a parameter, and page.url.pathname is passed directly from the template — ensuring the template re-evaluates reactively on navigation.
Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| event="platforms" | ||
| href={`${path}/platforms`} | ||
| selected={isTabSelected('platforms')}>Platforms</Tab> | ||
| selected={isTabSelected('platforms', page.url.pathname)}>Platforms</Tab> |
There was a problem hiding this comment.
the reactivity issue was the problem. is there a cleaner approach?

The active tab in the Integrations section of the project overview page was not correctly reflecting the current route — both on simple routes (e.g.
/overview/api-keys) and nested routes (e.g./overview/api-keys/create).Root Cause
Two issues combined to cause the bug:
Reactivity:
page.url.pathnamewas accessed inside theisTabSelected()function closure. In Svelte 5 legacy mode components, reactive state accessed inside a function closure does not create a reactive dependency in the template — so the tab selection was computed once at layout mount (always on/platformsdue to the redirect) and never updated on navigation.Nested route matching:
endsWith()fails for nested routes like/api-keys/createsince the path no longer ends with/api-keys.Fix
isTabSelected()now acceptspathnameas a parameter, andpage.url.pathnameis passed directly from the template expression. This ensures Svelte's reactivity system properly tracks the dependency and re-evaluates on navigation — matching the pattern used inaccount/header.svelteandauth/header.svelte.Path-segment matching (
split('/').includes(key)) replacesendsWith()to correctly handle both simple and nested routes without partial-string false positives.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.