fix(mobile-ux): guard ScrollToTopAsync JS interop to prevent prerendering runtime error
This commit is contained in:
@@ -432,9 +432,17 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Ensure the JS module is loaded and the component is fully rendered before invoking interop.
|
||||||
|
if (!_isJsInitialized)
|
||||||
|
{
|
||||||
|
await InitViewportDetectionAsync();
|
||||||
|
}
|
||||||
var module = await EnsureViewportModuleAsync();
|
var module = await EnsureViewportModuleAsync();
|
||||||
|
if (module != null)
|
||||||
|
{
|
||||||
await module.InvokeVoidAsync("scrollToTop", ".reader-canvas");
|
await module.InvokeVoidAsync("scrollToTop", ".reader-canvas");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogWarning(ex, "Failed to scroll reader canvas to top.");
|
Logger.LogWarning(ex, "Failed to scroll reader canvas to top.");
|
||||||
|
|||||||
Reference in New Issue
Block a user