Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup Condition="'$(VisualStudioVersion)' == '17.0'">
<Version>9.0.8</Version>
<Version>9.0.9</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(VisualStudioVersion)' == '18.0'">
<Version>10.0.0-rc.2.1.0</Version>
<Version>10.0.0-rc.2.1.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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/

Expand Down Expand Up @@ -55,6 +55,7 @@ public partial class SelectCity

private readonly HashSet<string> _values = [];
private string? _searchText;
private bool _showSearch;

private string? GetActiveClass(string item) => CssBuilder.Default()
.AddClass("active", _values.Contains(item) && IsMultiple)
Expand All @@ -75,6 +76,32 @@ protected override void OnParametersSet()
{
_values.Clear();
}

if (ShowSearch == false)
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expression 'A == false' can be simplified to '!A'.

Suggested change
if (ShowSearch == false)
if (!ShowSearch)

Copilot uses AI. Check for mistakes.
{
_searchText = "";
}
}

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="firstRender"></param>
/// <returns></returns>
protected override async Task OnAfterRenderAsync(bool firstRender)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider removing the _showSearch field and handling ShowSearch changes in OnParametersSetAsync to simplify state management and JS invocation.

// Remove the _showSearch field and the OnAfterRenderAsync override entirely.
// Instead, detect ShowSearch changes in OnParametersSetAsync and invoke JS after the render.
private bool _previousShowSearch;

protected override async Task OnParametersSetAsync()
{
    await base.OnParametersSetAsync();

    // Reset search text when ShowSearch is turned off
    if (ShowSearch == false)
    {
        _searchText = "";
    }

    // Only call resetSearch JS when ShowSearch actually changes
    if (_previousShowSearch != ShowSearch)
    {
        _previousShowSearch = ShowSearch;
        // This will run after the component has rendered the new state
        await InvokeVoidAsync("resetSearch", Id, ShowSearch);
    }
}

{
await base.OnAfterRenderAsync(firstRender);

if (firstRender)
{
_showSearch = ShowSearch;
}

if (!_showSearch != ShowSearch)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: The logic in the conditional is confusing and may not behave as intended.

The condition uses a double negative, which is unclear and may cause logic errors. Simplifying it to if (_showSearch != ShowSearch) will improve readability and correctness.

Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean logic in this condition is incorrect. The expression !_showSearch != ShowSearch will be evaluated as (!_showSearch) != ShowSearch, which is likely not the intended behavior.

This should be changed to _showSearch != ShowSearch to properly detect when the ShowSearch property has changed.

Suggested change
if (!_showSearch != ShowSearch)
if (_showSearch != ShowSearch)

Copilot uses AI. Check for mistakes.
{
_showSearch = ShowSearch;
await InvokeVoidAsync("resetSearch", Id, ShowSearch);
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the return statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see line 7, 22, etc.), so this should have a semicolon for consistency.

Suggested change
return
return;

Copilot uses AI. Check for mistakes.
}

const popover = Popover.init(el, {
shownCallback: () => {
if (searchInput != null) {
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable searchInput is referenced in the callback but is not defined in scope at this point. The searchInput variable is only created later in the initSearch function (line 38), which is called after this popover is initialized.

This will cause a runtime error when the popover is shown. Consider moving the popover initialization to occur after the search input is initialized, or capture the searchInput reference in a way that allows the callback to access it when executed.

Copilot uses AI. Check for mistakes.
Expand All @@ -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)
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the function call. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see lines 7, 22, 32, etc.), so this should have a semicolon for consistency.

Suggested change
initSearch(region)
initSearch(region);

Copilot uses AI. Check for mistakes.
}
else {
disposeSearch(region);
}
}

const initSearch = region => {
const { el, invoke, options } = region;
const searchInput = el.querySelector(".search-text");
if (searchInput) {
Input.composition(searchInput, async v => {
Expand All @@ -31,7 +50,18 @@ export function init(id, invoke, options) {
});
}

Data.set(id, { el, popover, searchInput, search });
region.searchInput = searchInput;
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see line 54, 60), so this should have a semicolon for consistency.

Copilot uses AI. Check for mistakes.
region.search = search;
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see lines 53-54, 60), so this should have a semicolon for consistency.

Copilot uses AI. Check for mistakes.
}

const disposeSearch = region => {
const { searchInput, search } = region;
if (searchInput) {
Input.dispose(searchInput);
}
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see line 60), so this should have a semicolon for consistency.

Copilot uses AI. Check for mistakes.
if (search) {
EventHandler.off(search, 'click');
}
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see lines 53-54), so this should have a semicolon for consistency.

Copilot uses AI. Check for mistakes.
}

export function hide(id) {
Expand All @@ -46,14 +76,10 @@ export function dispose(id) {
const region = Data.get(id)
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see line 77, 81), so this should have a semicolon for consistency.

Suggested change
const region = Data.get(id)
const region = Data.get(id);

Copilot uses AI. Check for mistakes.
Data.remove(id)
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see line 76, 81), so this should have a semicolon for consistency.

Suggested change
Data.remove(id)
Data.remove(id);

Copilot uses AI. Check for mistakes.

const { popover, searchInput, search } = region;
const { popover } = region;
if (popover) {
Popover.dispose(popover);
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see line 76-77, 84), so this should have a semicolon for consistency.

Copilot uses AI. Check for mistakes.
}
if (searchInput) {
Input.dispose(searchInput);
}
if (search) {
EventHandler.off(search, 'click');
}

disposeSearch(region);
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the statement. While JavaScript has automatic semicolon insertion, the codebase appears to use explicit semicolons consistently (see line 76-77, 81), so this should have a semicolon for consistency.

Copilot uses AI. Check for mistakes.
}
Loading