react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

`useHref` passed to `RouterProvider` not respected for synthetic links

Open joshuajaco opened this issue 1 year ago โ€ข 0 comments

Provide a general summary of the issue here

The useHref function passed to RouterProvider is not being called for synthetic links. In our Next.js app this results in the data-href attribute missing the base path. Meaning when using CMD + left click to open the link in a new tab the URL is missing the base path.

Looks like it was forgotten in https://github.com/adobe/react-spectrum/pull/5864

๐Ÿค” Expected Behavior?

The base path is prepended to the data-href attribute

๐Ÿ˜ฏ Current Behavior

Using CMD + left click to open a synthetic link in a new tab results in an invalid URL.

๐Ÿ’ Possible Solution

Use useHref when setting the data-href attribute.

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

  1. visit https://codesandbox.io/p/sandbox/gallant-currying-l8p7xc?file=%2Fsrc%2FApp.js
  2. CMD + left click to open the link in a new tab
  3. see that the base path is missing

Version

[email protected]

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

MacOS, Windows

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

joshuajaco avatar May 08 '24 14:05 joshuajaco