From f1781157a3af257d892b583264731e7e32aa406d Mon Sep 17 00:00:00 2001 From: Elie Bariche <33458222+ebariche@users.noreply.github.com> Date: Thu, 1 Jun 2023 03:17:05 -0400 Subject: [PATCH] perf: Add DispatchNativePositionChange export --- .../Xaml/Controls/FocusVisual/SystemFocusVisual.wasm.cs | 3 +++ src/Uno.UI/ts/Windows/UI/Xaml/Input/FocusVisual.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Controls/FocusVisual/SystemFocusVisual.wasm.cs b/src/Uno.UI/UI/Xaml/Controls/FocusVisual/SystemFocusVisual.wasm.cs index 18221569c10e..1b5b4c5e9991 100644 --- a/src/Uno.UI/UI/Xaml/Controls/FocusVisual/SystemFocusVisual.wasm.cs +++ b/src/Uno.UI/UI/Xaml/Controls/FocusVisual/SystemFocusVisual.wasm.cs @@ -39,6 +39,9 @@ partial void DetachVisualPartial() #endif } +#if NET7_0_OR_GREATER + [JSExport] +#endif public static int DispatchNativePositionChange(int focusVisualId) { var element = UIElement.GetElementFromHandle(focusVisualId) as SystemFocusVisual; diff --git a/src/Uno.UI/ts/Windows/UI/Xaml/Input/FocusVisual.ts b/src/Uno.UI/ts/Windows/UI/Xaml/Input/FocusVisual.ts index 2c41d6271848..ba9a11da16e4 100644 --- a/src/Uno.UI/ts/Windows/UI/Xaml/Input/FocusVisual.ts +++ b/src/Uno.UI/ts/Windows/UI/Xaml/Input/FocusVisual.ts @@ -25,8 +25,12 @@ private static onDocumentScroll() { if (!FocusVisual.dispatchPositionChange) { - FocusVisual.dispatchPositionChange = (Module).mono_bind_static_method( - "[Uno.UI] Uno.UI.Xaml.Controls.SystemFocusVisual:DispatchNativePositionChange"); + if ((globalThis).DotnetExports !== undefined) { + FocusVisual.dispatchPositionChange = (globalThis).DotnetExports.UnoUI.Uno.UI.Xaml.Controls.SystemFocusVisual.DispatchNativePositionChange; + } else { + FocusVisual.dispatchPositionChange = (Module).mono_bind_static_method( + "[Uno.UI] Uno.UI.Xaml.Controls.SystemFocusVisual:DispatchNativePositionChange"); + } } FocusVisual.updatePosition();