-
Couldn't load subscription status.
- Fork 276
Open
Labels
Description
Describe the Bug
In the JSS Link component, anchor links don’t work when linktype is "anchor".
The current code:
const anchor = link.linktype !== 'anchor' && link.anchor ? #${link.anchor} : '';
So if linktype is "anchor", the # is never added even though the anchor value exists. Instead, the href ends up like /anchorname, which is treated as a path, not an in-page anchor.
To Reproduce
- Create a Link field in Sitecore with linktype: "anchor" and anchor: "my_anchor".
- Render it using in your JSS app.
- The output is instead of , so scrolling doesn't work.
{
"linktype": "anchor",
"href": "my_anchor",
"anchor": "my_anchor",
"text": "Go to Anchor"
}
Expected Behavior
If linktype === 'anchor' and an anchor value is present, the href should be #anchor, not /anchor.
Possible Fix
No response
Provide environment information
- Sitecore Version: 10.4
- JSS Version: 22.0.0
- Browser Name and version: Google Chrome Version 138.0.7204.101 (Official Build) (64-bit)
- Operating System and version (desktop or mobile): Windows Desktop
o-diepes