Skip to content

Fix Integrations tab not reflecting active route#2901

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-integrations-tab-selection
Closed

Fix Integrations tab not reflecting active route#2901
Copilot wants to merge 3 commits intomainfrom
copilot/fix-integrations-tab-selection

Conversation

Copy link
Contributor

Copilot AI commented Mar 5, 2026

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:

  1. Reactivity: page.url.pathname was accessed inside the isTabSelected() 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 /platforms due to the redirect) and never updated on navigation.

  2. Nested route matching: endsWith() fails for nested routes like /api-keys/create since the path no longer ends with /api-keys.

Fix

isTabSelected() now accepts pathname as a parameter, and page.url.pathname is 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 in account/header.svelte and auth/header.svelte.

Path-segment matching (split('/').includes(key)) replaces endsWith() to correctly handle both simple and nested routes without partial-string false positives.

- function isTabSelected(key: string) {
-     return page.url.pathname.endsWith(`/${key}`);
- }
+ function isTabSelected(key: string, pathname: string) {
+     return pathname.split('/').includes(key);
+ }
- selected={isTabSelected('platforms')}
+ selected={isTabSelected('platforms', page.url.pathname)}

💡 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.

@appwrite
Copy link

appwrite bot commented Mar 5, 2026

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Roll back Sites deployments instantly by switching between versions

Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix integrations tab not matching route selection Fix Integrations tab selection on nested routes Mar 5, 2026

function isTabSelected(key: string) {
return page.url.pathname.endsWith(`/${key}`);
return page.url.pathname.split('/').includes(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this is not the issue. The tab is incorrect even when I'm on /project-x-y/overview/api-keys

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Contributor Author

Copilot AI commented Mar 5, 2026

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:

  • o1.ingest.sentry.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/console/console/node_modules/.bin/vitest run (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Fix Integrations tab selection on nested routes Fix Integrations tab not reflecting active route Mar 5, 2026
event="platforms"
href={`${path}/platforms`}
selected={isTabSelected('platforms')}>Platforms</Tab>
selected={isTabSelected('platforms', page.url.pathname)}>Platforms</Tab>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reactivity issue was the problem. is there a cleaner approach?

@stnguyen90 stnguyen90 closed this Mar 5, 2026
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.

2 participants