From 17b6539796f0ed4ce23da2e88d0f520959908606 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Thu, 7 Sep 2023 09:59:35 +1000 Subject: Implemented a slightly better fix for focusing input dialogs --- Pages/Component/TagSelectDialog.razor | 5 ----- wwwroot/js/dialog.js | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Pages/Component/TagSelectDialog.razor b/Pages/Component/TagSelectDialog.razor index 88e1471..7be5c43 100644 --- a/Pages/Component/TagSelectDialog.razor +++ b/Pages/Component/TagSelectDialog.razor @@ -75,11 +75,6 @@ LoadTags(); } - protected override async Task OnAfterRenderAsync(bool firstRender) { - if(Visible) - await Task.Delay(100).ContinueWith(t => queryInput.FocusAsync()); - } - private void LoadTags() { db = dbFactory.CreateDbContext(); diff --git a/wwwroot/js/dialog.js b/wwwroot/js/dialog.js index 7ea141e..065014a 100644 --- a/wwwroot/js/dialog.js +++ b/wwwroot/js/dialog.js @@ -41,6 +41,11 @@ function setDialogVisibility(element, visible) { element.style.opacity = 1; element.style.visibility = 'visible'; bumpDialog(element); + + var input = element.querySelector('input[type="text"]'); + if(input) { + setTimeout(() => input.focus(), 100); + } } else { element.style.opacity = 0; element.style.visibility = 'hidden'; -- cgit v1.3