From bf955e5d6ccc2a94e7ddbfe2455e22d91f81adc8 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 11 Nov 2025 13:45:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=94=AF=E6=8C=81=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/SelectCity.razor.js | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.js b/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.js index 8c4e9a4d..311d51fe 100644 --- a/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.js +++ b/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.js @@ -1,13 +1,14 @@ -import Data from "../../BootstrapBlazor/modules/data.js" +import Data from "../../BootstrapBlazor/modules/data.js" import EventHandler from "../../BootstrapBlazor/modules/event-handler.js" import Input from "../../BootstrapBlazor/modules/input.js" import Popover from "../../BootstrapBlazor/modules/base-popover.js" export function init(id, invoke, options) { - const el = document.getElementById(id) + const el = document.getElementById(id); if (el === null) { return } + const popover = Popover.init(el, { shownCallback: () => { if (searchInput != null) { @@ -16,6 +17,24 @@ export function init(id, invoke, options) { } }); + const region = { el, invoke, options, popover }; + initSearch(region); + Data.set(id, region); +} + +export function resetSearch(id, search) { + const region = Data.get(id); + + if (search) { + initSearch(region) + } + else { + disposeSearch(region); + } +} + +const initSearch = region => { + const { el, invoke, options } = region; const searchInput = el.querySelector(".search-text"); if (searchInput) { Input.composition(searchInput, async v => { @@ -31,7 +50,18 @@ export function init(id, invoke, options) { }); } - Data.set(id, { el, popover, searchInput, search }); + region.searchInput = searchInput; + region.search = search; +} + +const disposeSearch = region => { + const { searchInput, search } = region; + if (searchInput) { + Input.dispose(searchInput); + } + if (search) { + EventHandler.off(search, 'click'); + } } export function hide(id) { @@ -46,14 +76,10 @@ export function dispose(id) { const region = Data.get(id) Data.remove(id) - const { popover, searchInput, search } = region; + const { popover } = region; if (popover) { Popover.dispose(popover); } - if (searchInput) { - Input.dispose(searchInput); - } - if (search) { - EventHandler.off(search, 'click'); - } + + disposeSearch(region); } From d54160811198cec5e8944ac479171de99c0c9663 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 11 Nov 2025 13:45:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E6=94=AF=E6=8C=81=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=8A=B6=E6=80=81=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/SelectCity.razor.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs b/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs index 5ba16656..9eac13fb 100644 --- a/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs +++ b/src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs @@ -1,4 +1,4 @@ -// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved. +// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Website: https://www.blazor.zone or https://argozhang.github.io/ @@ -55,6 +55,7 @@ public partial class SelectCity private readonly HashSet _values = []; private string? _searchText; + private bool _showSearch; private string? GetActiveClass(string item) => CssBuilder.Default() .AddClass("active", _values.Contains(item) && IsMultiple) @@ -75,6 +76,32 @@ protected override void OnParametersSet() { _values.Clear(); } + + if (ShowSearch == false) + { + _searchText = ""; + } + } + + /// + /// + /// + /// + /// + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await base.OnAfterRenderAsync(firstRender); + + if (firstRender) + { + _showSearch = ShowSearch; + } + + if (!_showSearch != ShowSearch) + { + _showSearch = ShowSearch; + await InvokeVoidAsync("resetSearch", Id, ShowSearch); + } } /// From f6cbe93c30a54c9c17acf52756b5973bb49501d4 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 11 Nov 2025 13:47:06 +0800 Subject: [PATCH 3/3] chore: bump version 9.0.9 --- .../BootstrapBlazor.Region/BootstrapBlazor.Region.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/BootstrapBlazor.Region/BootstrapBlazor.Region.csproj b/src/components/BootstrapBlazor.Region/BootstrapBlazor.Region.csproj index 91a9a635..52d4ef57 100644 --- a/src/components/BootstrapBlazor.Region/BootstrapBlazor.Region.csproj +++ b/src/components/BootstrapBlazor.Region/BootstrapBlazor.Region.csproj @@ -1,11 +1,11 @@  - 9.0.8 + 9.0.9 - 10.0.0-rc.2.1.0 + 10.0.0-rc.2.1.1