Skip to content

Commit

Permalink
[Nextjs][SDK] RichText component not forwarding query params (#1015)
Browse files Browse the repository at this point in the history
* fixed issue for sending queryparms with pathname

* remove console.log
  • Loading branch information
addy-pathania authored May 10, 2022
1 parent e43881e commit 70f0628
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/sitecore-jss-nextjs/src/components/RichText.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('RichText', () => {
const props = {
field: {
value:
'<div id="test"><h1>Hello!</h1><a href="/testpath/t1">t1</a><a href="/t2">t2</a></div>',
'<div id="test"><h1>Hello!</h1><a href="/testpath/t1?test=sample1">t1</a><a href="/t2">t2</a></div>',
},
internalLinksSelector: 'a[href^="/testpath"]',
};
Expand All @@ -119,7 +119,7 @@ describe('RichText', () => {
const link1 = links && links[0];
const link2 = links && links[1];

expect(link1!.href).to.equal('/testpath/t1');
expect(link1!.href).to.equal('/testpath/t1?test=sample1');
expect(link2!.href).to.equal('/t2');

link1 && link1.click();
Expand Down
2 changes: 1 addition & 1 deletion packages/sitecore-jss-nextjs/src/components/RichText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const RichText = (props: RichTextProps): JSX.Element => {

ev.preventDefault();

const pathname = (ev.target as HTMLAnchorElement).pathname;
const pathname = (ev.target as HTMLAnchorElement).href;

router.push(pathname, pathname, { locale: false });
};
Expand Down

0 comments on commit 70f0628

Please sign in to comment.