Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unexpected token . at Microsoft.JSInterop.JSRuntime #581

Open
JimGeersinga opened this issue Jun 12, 2024 · 1 comment
Open

[Bug] Unexpected token . at Microsoft.JSInterop.JSRuntime #581

JimGeersinga opened this issue Jun 12, 2024 · 1 comment
Labels
Bug Something isn't working Triage Issue needs to be triaged

Comments

@JimGeersinga
Copy link

Describe the bug
Unexpected token . in Blazor Webview I'm encountering a SyntaxError: Unexpected token . in my Blazor Webview application. The error details are as follows:

blazor.webview.js:1 Unexpected token .
SyntaxError: Unexpected token .
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.JSInterop.IJSObjectReference, Microsoft.JSInterop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Blazored.Modal.BlazoredModal.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
NotifyUnhandledException @ blazor.webview.js:1

To Reproduce
Steps to reproduce the behavior:

  1. Create new .NET MAUI Hybrid project
  2. Add Blazored.Modal to the project
  3. Add CascadingBlazoredModal around the router as mentioned in the documentation
  4. Start app in android emulator.

Expected behavior
App starts normally without any errors and I am able to show a modal after button click

Screenshots
image

Hosting Model (is this issue happening with a certain hosting model?):

  • MAUI Blazor Hybrid

Additional context

This is how my Routes.Razor looks like

@using Blazored.Modal

<CascadingBlazoredModal>
    <Router AppAssembly="@typeof(MauiProgram).Assembly">
        <Found Context="routeData">
            <RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
            <FocusOnNavigate RouteData="@routeData" Selector="h1" />
        </Found>
    </Router>
</CascadingBlazoredModal>

I have tracked down the interop call location to this line in Blazored.Modal.

Looking at another (microsoft) component named QuickGrid I see that there is not really a difference.

@JimGeersinga JimGeersinga added Bug Something isn't working Triage Issue needs to be triaged labels Jun 12, 2024
@JimGeersinga
Copy link
Author

JimGeersinga commented Jun 12, 2024

With further looking into the problem it seems the ? in const overflowState = document.body?.style.overflow; is the problem.
I created a pull request to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant