Skip to content

fix: router links breaking on canvas#164

Merged
ruchamahabal merged 2 commits intofrappe:developfrom
ruchamahabal:fix-router-link
Apr 15, 2026
Merged

fix: router links breaking on canvas#164
ruchamahabal merged 2 commits intofrappe:developfrom
ruchamahabal:fix-router-link

Conversation

@ruchamahabal
Copy link
Copy Markdown
Member

@ruchamahabal ruchamahabal commented Apr 15, 2026

Problem

<router-link> inside components like Breadcrumbs fails because the Studio editor's Vue router doesn't have the app's routes registered. When router-link tries to resolve a route like { name: "Campaigns" } where Campaigns is an app page, it throws "No match for..." error, and the component does not render.

This only breaks for named routes ({ name: "Campaigns" }) not path routes ("/campaigns") because vue router's useLink tries to resolve named routes passed to it even before rendering the component.

image

But this will always be the case because studio's router would not resolve routes for the app that's being edited in edit mode

Fix 1:

Catch & ignore router errors in Studio Component renderer. App routes are not in the context of studio router so route resolution errors should not stop the component from rendering.

This only renders the path routes, not the named routes (that are invalid)

image

Fix 2:

patch router.resolve to resolve unmatched routes to the "Not Found" page. This ensures router-link renders correctly for the app being edited in studio

image

Why patch router.resolve and not use beforeResolve hook instead?

The issue is that resolves the route during its setup (when it calls useLink()), which happens before any navigation occurs. beforeResolve runs only on actual navigation, not when router-link resolves.

- app routes are not in the context of studio router so route resolution errors should not stop the component from rendering
- This ensures router-link renders correctly for the app being edited in studio
@ruchamahabal ruchamahabal merged commit 9067c76 into frappe:develop Apr 15, 2026
1 check passed
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