Skip to content

MudColorPicker: Use ParameterState#10357

Merged
ScarletKuro merged 12 commits intoMudBlazor:devfrom
ScarletKuro:colorpicker_param
Nov 24, 2025
Merged

MudColorPicker: Use ParameterState#10357
ScarletKuro merged 12 commits intoMudBlazor:devfrom
ScarletKuro:colorpicker_param

Conversation

@ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Nov 29, 2024

Description

Part of progression to stop violating our new rules to not write to components parameters.
Some methods were made private as I don't see point to expose them

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.

@github-actions github-actions bot added the breaking change This change will require consumer code updates label Nov 29, 2024
@ScarletKuro ScarletKuro mentioned this pull request Nov 23, 2025
3 tasks
@ScarletKuro ScarletKuro added the refactor Reorganizes code and has no changes to the API or functionality in the main library label Nov 23, 2025
@ScarletKuro ScarletKuro marked this pull request as ready for review November 23, 2025 22:18
@ScarletKuro
Copy link
Member Author

ScarletKuro commented Nov 23, 2025

@versile2 @danielchalmers does anyone wants to tests before I merge this? i didn't find problems vs current version.
I plan to refactor it later more and maybe eventually dig into the .net10 problem

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 migrates MudColorPicker to use the ParameterState pattern to avoid direct parameter mutations. The changes include refactoring the base MudPicker<T> class to support ParameterState through virtual proxy methods (ReadText/WriteTextAsync), and converting MudColorPicker to manage all its parameters (Value, Text, ShowAlpha, ColorPickerView, ThrottleInterval) through registered ParameterState instances. Several public API methods (SetR, SetG, SetB, SetH, SetS, SetL, SetAlpha, SetInputString, ChangeView) were either removed or changed to private/async variants, constituting breaking changes.

Key changes:

  • Introduction of ParameterState management for component parameters to prevent direct parameter mutations
  • Conversion of public setter methods to private async variants that work through ParameterState
  • Addition of MudColor.Empty static field and nullable support in MudColorComparer

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/MudBlazor/Utilities/MudColor.cs Added MudColor.Empty static field, reordered equality operators, and updated MudColorComparer to support nullable types
src/MudBlazor/Components/Picker/MudPicker.razor.cs Added virtual proxy methods (ReadText, WriteTextAsync, WriteValueAsync) to support ParameterState in derived classes, made _elementId readonly, changed TextChanged to nullable
src/MudBlazor/Components/Picker/MudPicker.razor Updated text binding to use split getter/setter syntax with proxy methods
src/MudBlazor/Components/ColorPicker/MudColorPicker.razor.cs Implemented ParameterState pattern with registration for all parameters, converted public setters to private async methods, added change handlers for parameter updates
src/MudBlazor/Components/ColorPicker/MudColorPicker.razor Updated all bindings to use ParameterState values and async setter methods
src/MudBlazor.UnitTests/Components/ColorPickerTests.cs Updated tests to use GetState() extension method for accessing ParameterState values
src/MudBlazor.UnitTests.Viewer/TestComponents/ColorPicker/SimpleColorPickerTest.razor Extracted inline lambda into named method for TextChanged event handler

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

@danielchalmers
Copy link
Member

danielchalmers commented Nov 23, 2025

is it laggy on your end?

Docs:

Recording.2025-11-23.172515.mp4

this branch on WasmHost:

Recording.2025-11-23.172431.mp4

@mudbot mudbot bot added the performance Time/memory/CPU/allocation performance characteristics label Nov 23, 2025
@ScarletKuro
Copy link
Member Author

is it laggy on your end?

No, looks smooth like on first gif? Try to run without debugger?

@ScarletKuro ScarletKuro removed the performance Time/memory/CPU/allocation performance characteristics label Nov 23, 2025
@ScarletKuro ScarletKuro merged commit 01827d8 into MudBlazor:dev Nov 24, 2025
5 of 6 checks passed
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

breaking change This change will require consumer code updates refactor Reorganizes code and has no changes to the API or functionality in the main library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants