From be36feec7bdd92077bbbdfe69ab255b28627ca3a Mon Sep 17 00:00:00 2001 From: Surayya Huseyn Zada Date: Mon, 20 Mar 2023 09:59:05 +0100 Subject: [PATCH 01/32] implemented scrolling to location hash --- .../src/DomWrapperInterop.cs | 4 +++- .../Microsoft.AspNetCore.Components.csproj | 11 ++++------ .../Components/src/Routing/Router.cs | 16 ++++++++++++++ src/Components/Web.JS/src/DomWrapper.ts | 19 +++++++++++++++++ .../Web.JS/src/Services/NavigationManager.ts | 21 +++++++++++++++---- .../Web/src/Routing/FocusOnNavigate.cs | 2 +- 6 files changed, 60 insertions(+), 13 deletions(-) rename src/Components/{Web => Components}/src/DomWrapperInterop.cs (70%) diff --git a/src/Components/Web/src/DomWrapperInterop.cs b/src/Components/Components/src/DomWrapperInterop.cs similarity index 70% rename from src/Components/Web/src/DomWrapperInterop.cs rename to src/Components/Components/src/DomWrapperInterop.cs index 0c6a1e0a54be..ddec3382569e 100644 --- a/src/Components/Web/src/DomWrapperInterop.cs +++ b/src/Components/Components/src/DomWrapperInterop.cs @@ -9,5 +9,7 @@ internal static class DomWrapperInterop public const string Focus = Prefix + "focus"; - public const string FocusBySelector = Prefix + "focusBySelector"; + public const string FocusOnNavigate = Prefix + "focusOnNavigate"; + + public const string ScrollToElement = Prefix + "scrollToElement"; } diff --git a/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj b/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj index 7729a85f705e..37c8d9b166b5 100644 --- a/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj +++ b/src/Components/Components/src/Microsoft.AspNetCore.Components.csproj @@ -22,6 +22,7 @@ + From 2d93d36676065455fd81994a672c681cbe8b6ba2 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 5 Apr 2023 18:28:02 +0100 Subject: [PATCH 27/32] Add pathbase support to Photino WebView so we can run the router E2E tests there --- .../WebView/WebView/src/PageContext.cs | 4 ++ .../Services/WebViewScrollToLocationHash.cs | 38 ++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/Components/WebView/WebView/src/PageContext.cs b/src/Components/WebView/WebView/src/PageContext.cs index 0230ccd99c54..9b198fb8d0df 100644 --- a/src/Components/WebView/WebView/src/PageContext.cs +++ b/src/Components/WebView/WebView/src/PageContext.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web.Infrastructure; using Microsoft.AspNetCore.Components.WebView.Services; @@ -46,6 +47,9 @@ public PageContext( var loggerFactory = ServiceProvider.GetRequiredService(); var jsComponents = new JSComponentInterop(jsComponentsConfiguration); Renderer = new WebViewRenderer(ServiceProvider, dispatcher, ipcSender, loggerFactory, JSRuntime, jsComponents); + + var webViewScrollToLocationHash = (WebViewScrollToLocationHash)ServiceProvider.GetRequiredService(); + webViewScrollToLocationHash.AttachJSRuntime(JSRuntime); } public async ValueTask DisposeAsync() diff --git a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs index 8976b5351b9e..76e604824090 100644 --- a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs +++ b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs @@ -2,10 +2,46 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Components.Routing; +using Microsoft.JSInterop; namespace Microsoft.AspNetCore.Components.WebView.Services; internal sealed class WebViewScrollToLocationHash : IScrollToLocationHash { - public Task RefreshScrollPositionForHash(string locationAbsolute) => Task.CompletedTask; + private IJSRuntime _jsRuntime; + + public void AttachJSRuntime(IJSRuntime jsRuntime) + { + if (HasAttachedJSRuntime) + { + throw new InvalidOperationException("JSRuntime has already been initialized."); + } + + _jsRuntime = jsRuntime; + } + + public bool HasAttachedJSRuntime => _jsRuntime != null; + + public async Task RefreshScrollPositionForHash(string locationAbsolute) + { + //JSRuntime = (WebViewJSRuntime)ServiceProvider.GetRequiredService(); + if (!HasAttachedJSRuntime) + { + // We should generally never get here in the ordinary case. Router will only call this API once pre-rendering is complete. + // This would guard any unusual usage of this API. + throw new InvalidOperationException("Navigation commands can not be issued at this time. This is because the component is being " + + "prerendered and the page has not yet loaded in the browser or because the circuit is currently disconnected. " + + "Components must wrap any navigation calls in conditional logic to ensure those navigation calls are not " + + "attempted during prerendering or while the client is disconnected."); + } + + var hashIndex = locationAbsolute.IndexOf("#", StringComparison.CurrentCultureIgnoreCase); + + if (hashIndex > -1 && locationAbsolute.Length > hashIndex + 1) + { + var elementId = locationAbsolute[(hashIndex + 1)..]; + + await _jsRuntime.InvokeVoidAsync("Blazor._internal.navigationManager.scrollToElement", elementId).AsTask(); + } + } } From 2786e530095baeb3fc6dcdf92fe786fdedacc0b4 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 5 Apr 2023 18:28:02 +0100 Subject: [PATCH 28/32] implemented WebViewScrollToLocationHash --- .../WebView/WebView/src/PageContext.cs | 4 ++ .../Services/WebViewScrollToLocationHash.cs | 38 ++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/Components/WebView/WebView/src/PageContext.cs b/src/Components/WebView/WebView/src/PageContext.cs index 0230ccd99c54..9b198fb8d0df 100644 --- a/src/Components/WebView/WebView/src/PageContext.cs +++ b/src/Components/WebView/WebView/src/PageContext.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web.Infrastructure; using Microsoft.AspNetCore.Components.WebView.Services; @@ -46,6 +47,9 @@ public PageContext( var loggerFactory = ServiceProvider.GetRequiredService(); var jsComponents = new JSComponentInterop(jsComponentsConfiguration); Renderer = new WebViewRenderer(ServiceProvider, dispatcher, ipcSender, loggerFactory, JSRuntime, jsComponents); + + var webViewScrollToLocationHash = (WebViewScrollToLocationHash)ServiceProvider.GetRequiredService(); + webViewScrollToLocationHash.AttachJSRuntime(JSRuntime); } public async ValueTask DisposeAsync() diff --git a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs index 8976b5351b9e..76e604824090 100644 --- a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs +++ b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs @@ -2,10 +2,46 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Components.Routing; +using Microsoft.JSInterop; namespace Microsoft.AspNetCore.Components.WebView.Services; internal sealed class WebViewScrollToLocationHash : IScrollToLocationHash { - public Task RefreshScrollPositionForHash(string locationAbsolute) => Task.CompletedTask; + private IJSRuntime _jsRuntime; + + public void AttachJSRuntime(IJSRuntime jsRuntime) + { + if (HasAttachedJSRuntime) + { + throw new InvalidOperationException("JSRuntime has already been initialized."); + } + + _jsRuntime = jsRuntime; + } + + public bool HasAttachedJSRuntime => _jsRuntime != null; + + public async Task RefreshScrollPositionForHash(string locationAbsolute) + { + //JSRuntime = (WebViewJSRuntime)ServiceProvider.GetRequiredService(); + if (!HasAttachedJSRuntime) + { + // We should generally never get here in the ordinary case. Router will only call this API once pre-rendering is complete. + // This would guard any unusual usage of this API. + throw new InvalidOperationException("Navigation commands can not be issued at this time. This is because the component is being " + + "prerendered and the page has not yet loaded in the browser or because the circuit is currently disconnected. " + + "Components must wrap any navigation calls in conditional logic to ensure those navigation calls are not " + + "attempted during prerendering or while the client is disconnected."); + } + + var hashIndex = locationAbsolute.IndexOf("#", StringComparison.CurrentCultureIgnoreCase); + + if (hashIndex > -1 && locationAbsolute.Length > hashIndex + 1) + { + var elementId = locationAbsolute[(hashIndex + 1)..]; + + await _jsRuntime.InvokeVoidAsync("Blazor._internal.navigationManager.scrollToElement", elementId).AsTask(); + } + } } From 4bb685e1044cf6dfd543acb17dc6e667a814a446 Mon Sep 17 00:00:00 2001 From: Surayya Huseyn Zada Date: Thu, 6 Apr 2023 12:24:22 +0200 Subject: [PATCH 29/32] small fix --- .../WebView/src/Services/WebViewScrollToLocationHash.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs index 76e604824090..7a3a58c0286c 100644 --- a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs +++ b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs @@ -24,15 +24,9 @@ public void AttachJSRuntime(IJSRuntime jsRuntime) public async Task RefreshScrollPositionForHash(string locationAbsolute) { - //JSRuntime = (WebViewJSRuntime)ServiceProvider.GetRequiredService(); if (!HasAttachedJSRuntime) { - // We should generally never get here in the ordinary case. Router will only call this API once pre-rendering is complete. - // This would guard any unusual usage of this API. - throw new InvalidOperationException("Navigation commands can not be issued at this time. This is because the component is being " + - "prerendered and the page has not yet loaded in the browser or because the circuit is currently disconnected. " + - "Components must wrap any navigation calls in conditional logic to ensure those navigation calls are not " + - "attempted during prerendering or while the client is disconnected."); + throw new InvalidOperationException("JSRuntime has not been attached."); } var hashIndex = locationAbsolute.IndexOf("#", StringComparison.CurrentCultureIgnoreCase); From bdaf5355fc92432eba36d8b8b5edc6ff15bfad2e Mon Sep 17 00:00:00 2001 From: Surayya Huseyn Zada Date: Thu, 6 Apr 2023 12:47:16 +0200 Subject: [PATCH 30/32] include _index in history.push() --- .../Web.JS/src/Services/NavigationManager.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Components/Web.JS/src/Services/NavigationManager.ts b/src/Components/Web.JS/src/Services/NavigationManager.ts index ea54413a382b..a30f9687542f 100644 --- a/src/Components/Web.JS/src/Services/NavigationManager.ts +++ b/src/Components/Web.JS/src/Services/NavigationManager.ts @@ -110,8 +110,8 @@ function isSamePageWithHash(absoluteHref: string): boolean { return hashIndex > -1 && location.href.replace(location.hash, '') === absoluteHref.substring(0, hashIndex); } -function performScrollToElementOnTheSamePage(absoluteHref : string): void { - history.pushState({}, "", absoluteHref); +function performScrollToElementOnTheSamePage(absoluteHref : string, replace: boolean, state: string | undefined = undefined): void { + saveToBrowserHistory(absoluteHref, replace, state); const hashIndex = absoluteHref.indexOf('#'); if (hashIndex == absoluteHref.length - 1) { @@ -174,7 +174,7 @@ async function performInternalNavigation(absoluteInternalHref: string, intercept ignorePendingNavigation(); if (isSamePageWithHash(absoluteInternalHref)) { - performScrollToElementOnTheSamePage(absoluteInternalHref); + performScrollToElementOnTheSamePage(absoluteInternalHref, replace, state); return; } @@ -192,6 +192,12 @@ async function performInternalNavigation(absoluteInternalHref: string, intercept // we render the new page. As a best approximation, wait until the next batch. resetScrollAfterNextBatch(); + saveToBrowserHistory(absoluteInternalHref, replace, state); + + await notifyLocationChanged(interceptedLink); +} + +function saveToBrowserHistory(absoluteInternalHref: string, replace: boolean, state: string | undefined = undefined): void { if (!replace) { currentHistoryIndex++; history.pushState({ @@ -204,8 +210,6 @@ async function performInternalNavigation(absoluteInternalHref: string, intercept _index: currentHistoryIndex, }, /* ignored title */ '', absoluteInternalHref); } - - await notifyLocationChanged(interceptedLink); } function navigateHistoryWithoutPopStateCallback(delta: number): Promise { From 697d8be071c12440a4612bd1c36a61be2b0a6793 Mon Sep 17 00:00:00 2001 From: Surayya Huseyn Zada <114938397+surayya-MS@users.noreply.github.com> Date: Thu, 6 Apr 2023 16:51:23 +0200 Subject: [PATCH 31/32] Update src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs Co-authored-by: Steve Sanderson --- .../Server/src/Circuits/RemoteScrollToLocationHash.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs b/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs index 9752eaa83318..56db7e3a06de 100644 --- a/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs +++ b/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs @@ -35,7 +35,7 @@ public async Task RefreshScrollPositionForHash(string locationAbsolute) "attempted during prerendering or while the client is disconnected."); } - var hashIndex = locationAbsolute.IndexOf("#", StringComparison.CurrentCultureIgnoreCase); + var hashIndex = locationAbsolute.IndexOf("#", StringComparison.Ordinal); if (hashIndex > -1 && locationAbsolute.Length > hashIndex + 1) { From 26171452e696766f80392eea2ad7199c8515554a Mon Sep 17 00:00:00 2001 From: Surayya Huseyn Zada Date: Thu, 6 Apr 2023 17:26:21 +0200 Subject: [PATCH 32/32] 1. Use StringComparison.Ordinal when searching for '#' 2. Prevent scrolling in focusOnNavigate 3. Removed test that checks scrolling to a named element with FocusOnNavigate --- .../Components/test/Routing/RouterTest.cs | 2 -- .../Circuits/RemoteScrollToLocationHash.cs | 2 +- src/Components/Web.JS/src/DomWrapper.ts | 15 ++------ src/Components/Web/src/DomWrapperInterop.cs | 2 +- .../Web/src/Routing/FocusOnNavigate.cs | 2 +- .../WebAssemblyScrollToLocationHash.cs | 2 +- .../Services/WebViewScrollToLocationHash.cs | 2 +- .../test/E2ETest/Tests/RoutingTest.cs | 36 ------------------- .../RouterTest/LongPageWithHash.razor | 4 --- .../RouterTest/LongPageWithHash3.razor | 24 ------------- 10 files changed, 7 insertions(+), 84 deletions(-) delete mode 100644 src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash3.razor diff --git a/src/Components/Components/test/Routing/RouterTest.cs b/src/Components/Components/test/Routing/RouterTest.cs index 7906d0175ee1..ba6cebcb3e6e 100644 --- a/src/Components/Components/test/Routing/RouterTest.cs +++ b/src/Components/Components/test/Routing/RouterTest.cs @@ -223,8 +223,6 @@ public Task EnableNavigationInterceptionAsync() internal sealed class TestScrollToLocationHash : IScrollToLocationHash { - public static readonly TestScrollToLocationHash Instance = new TestScrollToLocationHash(); - public Task RefreshScrollPositionForHash(string locationAbsolute) { return Task.CompletedTask; diff --git a/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs b/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs index 9752eaa83318..81a5c768e775 100644 --- a/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs +++ b/src/Components/Server/src/Circuits/RemoteScrollToLocationHash.cs @@ -41,7 +41,7 @@ public async Task RefreshScrollPositionForHash(string locationAbsolute) { var elementId = locationAbsolute[(hashIndex + 1)..]; - await _jsRuntime.InvokeVoidAsync(Interop.ScrollToElement, elementId).AsTask(); + await _jsRuntime.InvokeVoidAsync(Interop.ScrollToElement, elementId); } } } diff --git a/src/Components/Web.JS/src/DomWrapper.ts b/src/Components/Web.JS/src/DomWrapper.ts index 3d1847dd4526..5bc5f8058536 100644 --- a/src/Components/Web.JS/src/DomWrapper.ts +++ b/src/Components/Web.JS/src/DomWrapper.ts @@ -5,7 +5,7 @@ import '@microsoft/dotnet-js-interop'; export const domFunctions = { focus, - focusOnNavigate + focusBySelector }; function focus(element: HTMLOrSVGElement, preventScroll: boolean): void { @@ -22,11 +22,6 @@ function focus(element: HTMLOrSVGElement, preventScroll: boolean): void { } } -function focusOnNavigate(selector: string): void { - const preventScroll = location.hash.length > 1 && elementExists(location.hash.slice(1)); - focusBySelector(selector, preventScroll); -} - function focusBySelector(selector: string, preventScroll: boolean): void { const element = document.querySelector(selector) as HTMLElement; if (element) { @@ -37,12 +32,6 @@ function focusBySelector(selector: string, preventScroll: boolean): void { element.tabIndex = -1; } - element.focus({ preventScroll: preventScroll }); + element.focus({ preventScroll: true }); } -} - -function elementExists(identifier: string): boolean { - const element = document.getElementById(identifier) - || document.getElementsByName(identifier)[0]; - return !!element; } \ No newline at end of file diff --git a/src/Components/Web/src/DomWrapperInterop.cs b/src/Components/Web/src/DomWrapperInterop.cs index 1e8c207cdc8c..0c6a1e0a54be 100644 --- a/src/Components/Web/src/DomWrapperInterop.cs +++ b/src/Components/Web/src/DomWrapperInterop.cs @@ -9,5 +9,5 @@ internal static class DomWrapperInterop public const string Focus = Prefix + "focus"; - public const string FocusOnNavigate = Prefix + "focusOnNavigate"; + public const string FocusBySelector = Prefix + "focusBySelector"; } diff --git a/src/Components/Web/src/Routing/FocusOnNavigate.cs b/src/Components/Web/src/Routing/FocusOnNavigate.cs index d7134a1373ee..468e15c86068 100644 --- a/src/Components/Web/src/Routing/FocusOnNavigate.cs +++ b/src/Components/Web/src/Routing/FocusOnNavigate.cs @@ -56,7 +56,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) if (_focusAfterRender) { _focusAfterRender = false; - await JSRuntime.InvokeVoidAsync(DomWrapperInterop.FocusOnNavigate, Selector); + await JSRuntime.InvokeVoidAsync(DomWrapperInterop.FocusBySelector, Selector); } } diff --git a/src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyScrollToLocationHash.cs b/src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyScrollToLocationHash.cs index a5efe956cf92..10f642582130 100644 --- a/src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyScrollToLocationHash.cs +++ b/src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyScrollToLocationHash.cs @@ -11,7 +11,7 @@ internal sealed class WebAssemblyScrollToLocationHash : IScrollToLocationHash public Task RefreshScrollPositionForHash(string locationAbsolute) { - var hashIndex = locationAbsolute.IndexOf("#", StringComparison.CurrentCultureIgnoreCase); + var hashIndex = locationAbsolute.IndexOf("#", StringComparison.Ordinal); if (hashIndex > -1 && locationAbsolute.Length > hashIndex + 1) { diff --git a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs index 7a3a58c0286c..c7fa89be4377 100644 --- a/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs +++ b/src/Components/WebView/WebView/src/Services/WebViewScrollToLocationHash.cs @@ -29,7 +29,7 @@ public async Task RefreshScrollPositionForHash(string locationAbsolute) throw new InvalidOperationException("JSRuntime has not been attached."); } - var hashIndex = locationAbsolute.IndexOf("#", StringComparison.CurrentCultureIgnoreCase); + var hashIndex = locationAbsolute.IndexOf("#", StringComparison.Ordinal); if (hashIndex > -1 && locationAbsolute.Length > hashIndex + 1) { diff --git a/src/Components/test/E2ETest/Tests/RoutingTest.cs b/src/Components/test/E2ETest/Tests/RoutingTest.cs index 92dafbabc5ae..8bdfb75eaa35 100644 --- a/src/Components/test/E2ETest/Tests/RoutingTest.cs +++ b/src/Components/test/E2ETest/Tests/RoutingTest.cs @@ -1578,42 +1578,6 @@ public void AnchorWithHrefContainingHash_NavigatesToPageAndScrollsToElementWithN Assert.Equal(test2VerticalLocation, currentWindowScrollY); } - [Fact] - public void AnchorWithHrefContainingHash_FocusOnNavigatePreventScrollAndScrollsToElementWithId() - { - SetUrlViaPushState("/"); - var app = Browser.MountTestComponent(); - app.FindElement(By.LinkText("Long page with hash")).Click(); - - app.FindElement(By.Id("anchor-test3")).Click(); - - var currentWindowScrollY = BrowserScrollY; - var test3VerticalLocation = app.FindElement(By.Id("test3")).Location.Y; - var focusOnNavigateSelectorVerticalLocation = app.FindElement(By.Id("test-info")).Location.Y; - var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString(); - Assert.Equal("subdir/LongPageWithHash3#test3", currentRelativeUrl); - Assert.Equal(test3VerticalLocation, currentWindowScrollY); - Assert.NotEqual(focusOnNavigateSelectorVerticalLocation, currentWindowScrollY); - } - - [Fact] - public void AnchorWithHrefContainingHash_FocusOnNavigatePreventScrollAndScrollsToElementWithName() - { - SetUrlViaPushState("/"); - var app = Browser.MountTestComponent(); - app.FindElement(By.LinkText("Long page with hash")).Click(); - - app.FindElement(By.Id("anchor-test4")).Click(); - - var currentWindowScrollY = BrowserScrollY; - var test3VerticalLocation = app.FindElement(By.Name("test4")).Location.Y; - var focusOnNavigateSelectorVerticalLocation = app.FindElement(By.Id("test-info")).Location.Y; - var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString(); - Assert.Equal("subdir/LongPageWithHash3#test4", currentRelativeUrl); - Assert.Equal(test3VerticalLocation, currentWindowScrollY); - Assert.NotEqual(focusOnNavigateSelectorVerticalLocation, currentWindowScrollY); - } - [Fact] public void NavigatationManagerNavigateToSameUrlWithHash_ScrollsToElementWithIdOnTheSamePage() { diff --git a/src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash.razor b/src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash.razor index c5b398685181..6de0c230a348 100644 --- a/src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash.razor +++ b/src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash.razor @@ -5,10 +5,6 @@
Go to test2 on LongPageWithHash2 page
-Go to test3 on LongPageWithHash3 page (contains focus on navigate selector) -
-Go to test4 on LongPageWithHash3 page (contains focus on navigate selector) -

diff --git a/src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash3.razor b/src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash3.razor deleted file mode 100644 index 1d8ebe45798d..000000000000 --- a/src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash3.razor +++ /dev/null @@ -1,24 +0,0 @@ -@page "/LongPageWithHash3" -@inject NavigationManager NavigationManager - -
- Scroll past me to find the links -
- -

Test3

- -
- Scroll past me to find the links -
- -

Test4

- -
- Scroll past me to find the links -
- -

Focus On Navigate Selector

- -
- Scroll past me to find the links -