From 01b3e1d17a4c1e597fffbd75716733d36f54643e Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 26 Jan 2025 00:45:43 +0800 Subject: [PATCH] feat(Drawer): auto focus when drawer shown (#5211) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: add auto focus logic * refactor: 重构代码 * refactor: 精简代码 * chore: bump version 9.3.1-beta01 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- src/BootstrapBlazor/Components/Drawer/Drawer.razor.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index b1c770c61ef..be4a63ed475 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.3.0 + 9.3.1-beta01 diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.js b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.js index ebe2a0301b5..9b021754c74 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.js +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.js @@ -100,7 +100,8 @@ export function execute(id, open) { requestAnimationFrame(show); } else { - drawerBody.classList.add('show') + drawerBody.classList.add('show'); + el.focus(); } } @@ -123,11 +124,9 @@ export function execute(id, open) { body.classList.add('overflow-hidden') requestAnimationFrame(show) } - else { - if (el.classList.contains('show')) { - drawerBody.classList.remove('show') - requestAnimationFrame(hide) - } + else if (el.classList.contains('show')) { + drawerBody.classList.remove('show') + requestAnimationFrame(hide) } }