Skip to content

Make select just to be select - Remove dropdown and simply style#98

Merged
LittleLittleCloud merged 6 commits intomainfrom
u/xiaoyun/improveSelect
Nov 6, 2025
Merged

Make select just to be select - Remove dropdown and simply style#98
LittleLittleCloud merged 6 commits intomainfrom
u/xiaoyun/improveSelect

Conversation

@LittleLittleCloud
Copy link
Member

image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Select component to simplify its UI by removing the dropdown toggle behavior and always displaying all options. The changes convert it from a collapsible dropdown to an always-visible list-style selector.

  • Removed the dropdown toggle mechanism and related UI (input box with Panel, placeholder/value display logic, empty state)
  • Simplified the rendering to always show all options with highlight indicator
  • Updated the gallery example to use two-way binding (@bind-Value) instead of one-way Value parameter

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/RazorConsole.Core/Components/Select.razor Refactored to always display all options in a list format, removed dropdown toggle functionality, simplified styling logic, removed unused parameters (Placeholder, BorderStyle, etc.)
src/RazorConsole.Gallery/Components/SelectGallery.razor Updated example to use @bind-Value binding and initialized Select field with default value
Comments suppressed due to low confidence (3)

src/RazorConsole.Core/Components/Select.razor:177

  • The _isOpen checks in keyboard handling are now obsolete since the options are always visible. These conditions should be updated to reflect the new always-visible behavior.
        if (IsCommitKey(key) && _isOpen && _highlightedValue is not null)
        {
            await SelectOptionAsync(_highlightedValue).ConfigureAwait(false);
            return;
        }

        if (IsCancelKey(key) && _isOpen)
        {
            _isOpen = false;
            _highlightedValue = _selectedValue;
            await InvokeAsync(StateHasChanged).ConfigureAwait(false);
            return;
        }

src/RazorConsole.Core/Components/Select.razor:294

  • The EnsureOpen method is now obsolete since the component no longer has open/closed states. This method should be refactored or removed.
    private bool EnsureOpen()
    {
        if (_isOpen)
        {
            EnsureHighlightedValue();
            return false;
        }

        _isOpen = true;

        EnsureHighlightedValue();

        return true;
    }

src/RazorConsole.Core/Components/Select.razor:359

  • The _isOpen check in SyncHighlightedValue is now obsolete. Since options are always visible, this method should be simplified.
    private void SyncHighlightedValue()
    {
        if (_isOpen)
        {
            EnsureHighlightedValue();
            return;
        }

        _highlightedValue = _selectedValue;
    }

Comment on lines 127 to 131
private void OnFocus()
{
_isFocused = true;
_inputBorderColor = Color.Yellow;
}
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

The assignment to _inputBorderColor is now unused since the field is no longer rendered. Remove this line.

Copilot uses AI. Check for mistakes.
LittleLittleCloud and others added 3 commits November 5, 2025 17:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
@LittleLittleCloud LittleLittleCloud enabled auto-merge (squash) November 6, 2025 01:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (5)

src/RazorConsole.Core/Components/Select.razor:94

  • The field _isOpen is referenced but was removed in the diff (previously at line 32). This will cause compilation errors. Since the component no longer has dropdown toggle behavior, this method should either be removed or refactored to not use _isOpen.
        if (_isOpen)
        {
            EnsureHighlightedValue();
            _isOpen = false;
        }
        else
        {
            _isOpen = true;
        }

src/RazorConsole.Core/Components/Select.razor:160

  • The field _isOpen is referenced but was removed in the diff. This condition check will cause a compilation error.
        if (IsCommitKey(key) && _isOpen && _highlightedValue is not null)

src/RazorConsole.Core/Components/Select.razor:168

  • The field _isOpen is referenced but was removed in the diff. Both the condition and assignment will cause compilation errors.
        if (IsCancelKey(key) && _isOpen)
        {
            _isOpen = false;

src/RazorConsole.Core/Components/Select.razor:284

  • The field _isOpen is referenced but was removed in the diff. The EnsureOpen() method will fail to compile.
        if (_isOpen)
        {
            EnsureHighlightedValue();
            return false;
        }

        _isOpen = true;

src/RazorConsole.Core/Components/Select.razor:351

  • The field _isOpen is referenced but was removed in the diff. The SyncHighlightedValue() method will fail to compile.
        if (_isOpen)
        {
            EnsureHighlightedValue();
            return;
        }

@LittleLittleCloud
Copy link
Member Author

@copilot fix test error

Copy link
Contributor

Copilot AI commented Nov 6, 2025

@LittleLittleCloud I've opened a new pull request, #99, to work on those changes. Once the pull request is ready, I'll request review from you.

@LittleLittleCloud LittleLittleCloud merged commit 03d860f into main Nov 6, 2025
5 checks passed
@LittleLittleCloud LittleLittleCloud deleted the u/xiaoyun/improveSelect branch November 6, 2025 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants