Sitecore / jss

Software development kit for JavaScript developers building web applications with Sitecore Experience Platform
https://jss.sitecore.com
Apache License 2.0
262 stars 272 forks source link

Next.js RichText component not forwarding query params when clicking on internal links #990

Closed thaiphan closed 2 years ago

thaiphan commented 2 years ago

Description

I have the following rich text field...

<p>We are the <a href="/why-choose-us?overview=performance">fastest provider</a> available.</p>

If I click on the internal link, I am currently redirected to /why-choose-us. However, the ?overview=performance bit does not seem to get added to the URL.

Expected behavior

I would like for the search query parameter, i.e. ?overview=performance, to be appended to the URL whenever I click on a rich text internal link. We're using search query params a lot to control things like which tab on the page is currently open, etc.

Possible Fix

Maybe pass the value of link.search through to router.push somehow here: https://github.com/Sitecore/jss/blob/v21.0.0-canary.37/packages/sitecore-jss-nextjs/src/components/RichText.tsx#L42

Your Environment

ambrauer commented 2 years ago

@thaiphan thanks for the information, I've added this to our backlog to investigate / fix in a future release.

We also gladly accept pull requests if you'd like to take a stab at it. Check the contributing guide and we'll be happy to merge it in.

thaiphan commented 2 years ago

Do you think this is something that you can add as a patch?

addy-pathania commented 2 years ago

@thaiphan yes this would be a part of the next major release which could be possibly around early next month.