solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.14k stars 146 forks source link

`<A>` behaves incorrectly when using `explicitLinks={true}` #356

Closed LinqToException closed 8 months ago

LinqToException commented 8 months ago

Describe the bug

Clicking on any <A> while explicitLinks is true will cause the page to refresh, instead of doing a SPA-like load of the new component.

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-vmjslx?file=src%2Findex.tsx

Steps to Reproduce the Bug or Issue

  1. Create a new application with a few simple routes, a few links with <A> that lead to these routes, and set explicitLinks to true. See Stackblitz for example.
  2. Click on any <A> link that leads to another route.

Expected behavior

I expect the page to not refresh and instead transition to the new component/route that was selected.

Screenshots or Videos

No response

Platform

Additional context

codeprrr on Discord found a potential issue with this constellation:

// in handleAnchor function
if (!a || explicitLinks && !a.getAttribute("link")) return;

// but <A> has hardcoded prop
// that you can't overwrite:
"link": "",