2

Many browsers have built in features for translating a page. When users try this in my app however, it results in errors when navigating to a different page. This is the type of error that occurs: (standard diff errors)

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
  Unhandled exception rendering component: Cannot read properties of null (reading 'insertBefore')
  TypeError: Cannot read properties of null (reading 'insertBefore')
      at x (https://devolv.com/_framework/blazor.webassembly.js:1:17125)
      at M (https://devolv.com/_framework/blazor.webassembly.js:1:16836)
      at se.insertMarkup (https://devolv.com/_framework/blazor.webassembly.js:1:24546)
      at se.insertFrame (https://devolv.com/_framework/blazor.webassembly.js:1:23416)
      at se.applyEdits (https://devolv.com/_framework/blazor.webassembly.js:1:21490)
      at se.updateComponent (https://devolv.com/_framework/blazor.webassembly.js:1:20774)
      at https://devolv.com/_framework/blazor.webassembly.js:1:59513
      at Vt.Ke._internal.renderBatch (https://devolv.com/_framework/blazor.webassembly.js:1:59885)
      at Object.Gt [as invokeJSFromDotNet] (https://devolv.com/_framework/blazor.webassembly.js:1:62728)
      at Object.Ii (https://devolv.com/_framework/dotnet.7.0.2.85wfq42abb.js:5:71465)

It doesn't occur on all pages however, and I'm thinking it may have to do with if I do things in the OnAfterRender lifecycle method.

I have implemented localization in my app and I'd rather people use that. I looked into ways of preventing the use of google translate through <html class="notranslate"> and <meta name="googlebot" content="notranslate"> found in the answers of this question, but it didn't appear to work for the on-page translator that the user initializes themselves.

This error can be reproduced on other Blazor sites like MudBlazor by translating and spamming between pages, but it doesn't appear as often as with my site.

Anyone have any clues about ways to prevent this error?

Edit: After some investigating, this appears to happen on pages where the PageTitle component is used. Removing that component will prevent the error from occurring. I would still like to find some way around this though.

Axekan
  • 641
  • 5
  • 11

0 Answers0