Skip to content

MudSelect: Add SelectionOnEnter, Improve Pager keyboard UX#12405

Merged
danielchalmers merged 3 commits intoMudBlazor:devfrom
nccadman19:fix/tablepagers
Jan 13, 2026
Merged

MudSelect: Add SelectionOnEnter, Improve Pager keyboard UX#12405
danielchalmers merged 3 commits intoMudBlazor:devfrom
nccadman19:fix/tablepagers

Conversation

@nccadman19
Copy link
Contributor

@nccadman19 nccadman19 commented Jan 8, 2026

feat(MudSelect): add SelectionOnEnter and improve Pager keyboard UX

Related Issues
Fix #12404
Fix #9718

Summary

Introduces a new parameter SelectionOnEnter to MudSelect and enables it for MudTablePager and MudDataGridPager. This allows users to navigate dropdown options via keyboard without triggering an immediate value change, which is particularly beneficial for paginated components to prevent multiple expensive data reloads during navigation.

Key Changes

MudSelect
New Parameter: Added SelectionOnEnter (bool). When true, arrow key navigation only moves the visual highlight.
Logic Update: Refactored SelectAdjacentItem to skip SetValueAndUpdateTextAsync when SelectionOnEnter is enabled, requiring Enter or NumpadEnter to commit the selection.

Documentation
Updated the Keyboard Navigation section in the docs to explain the new behaviour and key bindings.

Pagers
MudTablePager & MudDataGridPager: Enabled SelectionOnEnter="true" by default. This fixes the "jumping" behaviour where the table would refresh for every arrow-key press when changing rows per page.

Testing
New Test Component: Created SelectTest3 specifically to verify the SelectionOnEnter state.
New Unit Test: Added SelectTest_SelectionOnEnter_ShouldOnlyChangeOnEnter to ensure value binding only occurs after the Enter key is pressed.

How Has This Been Tested?
Manual Verification: Tested in the MudBlazor.Docs environment to ensure that MudTable and MudDataGrid pagers no longer refresh until the user explicitly selects a new page size with Enter and that MudSelect works as expected for all others. Testing in MudBlazor.UnitTests.Viewer and it outputs the same results.
Unit Tests: Ran all tests. Original tests pass (preserving backward compatibility), and the new test confirms the "selection-on-enter" logic.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

Remaining Issues / Clarifications
N/A

New Parameter: Added SelectionOnEnter (bool). When true, arrow key navigation only moves the visual highlight.

Logic Update: Refactored SelectAdjacentItem to skip SetValueAndUpdateTextAsync when SelectionOnEnter is enabled, requiring Enter or NumpadEnter to commit the selection.

Documentation: Updated the Keyboard Navigation section in the docs to explain the new behavior and key bindings.

Pagers
MudTablePager & MudDataGridPager: Enabled SelectionOnEnter="true" by default. This fixes the "jumping" behavior where the table would refresh for every arrow-key press when changing rows per page.

Testing
New Test Component: Created SelectTest3 specifically to verify the SelectionOnEnter state.

New Unit Test: Added SelectTest_SelectionOnEnter_ShouldOnlyChangeOnEnter to ensure value binding only occurs after the Enter key is pressed.
@nccadman19 nccadman19 changed the title MudSelect MudSelect: Add SelectionOnEnter and improve Pager keyboard UX Jan 8, 2026
@mudbot mudbot bot added enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library accessibility Accessibility concerns (ARIA, keyboard, focus, screen readers, contrast) labels Jan 8, 2026
@ScarletKuro
Copy link
Member

@danielchalmers @versile2 wonder if it's something that should be by default. I see many frameworks require an enter, like MUI

@danielchalmers
Copy link
Member

@danielchalmers @versile2 wonder if it's something that should be by default. I see many frameworks require an enter, like MUI

I would probably stick with the native <select> behavior which doesn't require the enter key.

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 introduces a new SelectionOnEnter parameter to MudSelect that enables keyboard navigation without immediate value updates. When enabled, users must press Enter to confirm their selection, preventing expensive data reloads in paginated components.

Key Changes:

  • Added SelectionOnEnter boolean parameter to MudSelect (defaults to false for backward compatibility)
  • Modified arrow key navigation to only highlight items when SelectionOnEnter is enabled
  • Enabled SelectionOnEnter="true" in both MudTablePager and MudDataGridPager to prevent rapid table reloads

Reviewed changes

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

Show a summary per file
File Description
src/MudBlazor/Components/Select/MudSelect.razor.cs Added SelectionOnEnter parameter and modified SelectAdjacentItem to skip immediate value updates when enabled
src/MudBlazor/Components/Table/MudTablePager.razor Enabled SelectionOnEnter="true" on the rows-per-page selector
src/MudBlazor/Components/DataGrid/MudDataGridPager.razor Enabled SelectionOnEnter="true" on the rows-per-page selector
src/MudBlazor.UnitTests/Components/SelectTests.cs Added test to verify arrow keys don't change value until Enter is pressed
src/MudBlazor.UnitTests.Viewer/TestComponents/Select/SelectTest3.razor Created test component with SelectionOnEnter enabled for unit testing
src/MudBlazor.Docs/Pages/Components/Select/SelectPage.razor Updated keyboard navigation documentation to explain the new parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@versile2
Copy link
Contributor

versile2 commented Jan 9, 2026

@danielchalmers @versile2 wonder if it's something that should be by default. I see many frameworks require an enter, like MUI

That is absolutely tough. If it were a new control from scratch I would definitely do it by default, but I do think we desperately need this feature and yeah it shouldn't change existing functionality. There should be an additional doc setting explaining it too. - Opinion

@ScarletKuro
Copy link
Member

There should be an additional doc setting explaining it too. - Opinion

You mean an example or what? Since there was added a:

Set <CodeInline>SelectionOnEnter="true"</CodeInline> to move the visual highlight with arrow keys, requiring an

mention in the doc.

@nccadman19
Copy link
Contributor Author

nccadman19 commented Jan 12, 2026

Hey, I've updated the spacing in docs as requested by Copilot, is there anywhere else you want me to add documentation regarding this?

@danielchalmers @ScarletKuro @versile2

@danielchalmers danielchalmers changed the title MudSelect: Add SelectionOnEnter and improve Pager keyboard UX MudSelect: Add SelectionOnEnter, Improve Pager keyboard UX Jan 12, 2026
@danielchalmers danielchalmers merged commit 850cf6a into MudBlazor:dev Jan 13, 2026
2 checks passed
@danielchalmers
Copy link
Member

Thank you!

This was referenced Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Accessibility concerns (ARIA, keyboard, focus, screen readers, contrast) enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library

Projects

None yet

5 participants