MudBlazor: KeyInterceptor service breaks a in certain scenarios

Bug type

Component

Component name

mudKeyInterceptor.js

What happened?

I got the error in the log section when the page has a MudSelect, but I suspect it’s going to happen with every component that uses KeyInterceptor.

Note: I encountered this specific behaviour the first time on a .NET MAUI application, but I replicated it with regular mobile Chrome with the provided snippet.

The issue is that older version of chromium don’t support replaceAll, it has been available since v85 (first released on August 85).

Expected behavior

The solution would be using replace, which works exactly the same way when the pattern is a regular expression (tested). Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

I successfully tested the change myself.

Reproduction link

https://try.mudblazor.com/snippet/wumvllbyMJVZFbQo

Reproduction steps

It happens when rendering the specific component.

Relevant log output

"(keyOption.preventDown || "none").replaceAll is not a function
TypeError: (keyOption.preventDown || "none").replaceAll is not a function
    at MudKeyInterceptor.connect (https://0.0.0.0/_content/MudBlazor/MudBlazor.min.js:1:7950)
    at MudKeyInterceptorFactory.connect (https://0.0.0.0/_content/MudBlazor/MudBlazor.min.js:1:6328)
    at https://0.0.0.0/_framework/blazor.webview.js:1:3332
    at new Promise (<anonymous>)
    at beginInvokeJSFromDotNet (https://0.0.0.0/_framework/blazor.webview.js:1:3306)
    at External.callback (https://0.0.0.0/_framework/blazor.webview.js:1:40526)
    at MessagePort.<anonymous> (<anonymous>:23:33)
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d16`1[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at MudBlazor.Services.KeyInterceptor.Connect(String elementId, KeyInterceptorOptions options) in C:[redacted]\MudBlazor\src\MudBlazor\Services\KeyInterceptor\KeyInterceptor.cs:line 45
   at Microsoft.AspNetCore.Components.RenderTree.Ren11-15 00:04:23.673 I/chromium(16567):    at MudBlazor.MudSelect`1.<OnAfterRenderAsync>d__155[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() in C:[redacted]\MudBlazor\src\MudBlazor\Components\Select\MudSelect.razor.cs:line 695

Version (bug)

6.0.2

Version (working)

No response

What browsers are you seeing the problem on?

Chrome

On what operating system are you experiencing the issue?

Android

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (7 by maintainers)

Most upvoted comments

Sure, go ahead and PR please. We discovered it too but I didn’t put priority on fixing. Mention me in the PR.