Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/Components/Web.JS/src/Services/NavigationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ export function attachToEventDelegator(eventDelegator: EventDelegator): void {

if (anchorTarget && canProcessAnchor(anchorTarget)) {
let anchorHref = anchorTarget.getAttribute('href')!;
if (anchorHref.startsWith('#')) {
// Preserve the existing URL but set the hash to match the link that was clicked
anchorHref = `${location.origin}${location.pathname}${location.search}${anchorHref}`;
}

const absoluteHref = toAbsoluteUri(anchorHref);

Expand Down
4 changes: 2 additions & 2 deletions src/Components/test/E2ETest/Tests/RoutingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ public void CanNavigateBetweenPagesWithQueryStrings()
}

[Fact]
public void AnchorWithHrefStartingWithHash_ScrollsToElementWithIdOnTheSamePage()
public void AnchorWithHrefContainingHashSamePage_ScrollsToElementWithIdOnTheSamePage()
{
SetUrlViaPushState("/");
var app = Browser.MountTestComponent<TestRouter>();
Expand All @@ -1563,7 +1563,7 @@ public void AnchorWithHrefStartingWithHash_ScrollsToElementWithIdOnTheSamePage()
}

[Fact]
public void AnchorWithHrefContainingHash_NavigatesToPageAndScrollsToElementWithName()
public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToElementWithName()
{
SetUrlViaPushState("/");
var app = Browser.MountTestComponent<TestRouter>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@page "/LongPageWithHash"
@inject NavigationManager NavigationManager

<a id="anchor-test1" href="#test1">Go to test1 on this page</a>
<a id="anchor-test1" href="LongPageWithHash#test1">Go to test1 on this page</a>
<br/>
<a id="anchor-test2" href="/subdir/LongPageWithHash2#test2">Go to test2 on LongPageWithHash2 page</a>
<a id="anchor-test2" href="LongPageWithHash2#test2">Go to test2 on LongPageWithHash2 page</a>
<br />
<button id="navigate-test1" class="btn btn-primary" @onclick="GoToTest1">NavigationManager.NavigatteTo same page #test1</button>
<br />
Expand All @@ -22,11 +22,11 @@
@code {
void GoToTest1()
{
NavigationManager.NavigateTo("/subdir/LongPageWithHash#test1");
NavigationManager.NavigateTo("LongPageWithHash#test1");
}

void GoToTest2()
{
NavigationManager.NavigateTo("/subdir/LongPageWithHash2#test2");
NavigationManager.NavigateTo("LongPageWithHash2#test2");
}
}