Skip to content

MudColorPicker: Use ParameterState - #10357

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

ScarletKuro merged 12 commits into
MudBlazor:devfrom
ScarletKuro:colorpicker_param

Conversation

@ScarletKuro

@ScarletKuro ScarletKuro commented Nov 29, 2024 •

Copy link
Copy Markdown
Member

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 (ex: removes/changes an API) label Nov 29, 2024
@ScarletKuro ScarletKuro mentioned this pull request Nov 23, 2025
3 tasks done
@ScarletKuro ScarletKuro added the refactor Reorganizes code with no changes to the API or functionality in the main library or other benefits label Nov 23, 2025
@ScarletKuro
ScarletKuro marked this pull request as ready for review November 23, 2025 22:18
@ScarletKuro

ScarletKuro commented Nov 23, 2025 •

Copy link
Copy Markdown
Member Author

@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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/MudBlazor/Utilities/MudColor.cs Resolved
ScarletKuro and others added 2 commits November 24, 2025 01:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@danielchalmers

danielchalmers commented Nov 23, 2025 •

Copy link
Copy Markdown
Member

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 Related to time/memory/CPU/allocation performance characteristics label Nov 23, 2025
@ScarletKuro

Copy link
Copy Markdown
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 Related to time/memory/CPU/allocation performance characteristics label Nov 23, 2025
@ScarletKuro
ScarletKuro merged commit 01827d8 into MudBlazor:dev Nov 24, 2025
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 (ex: removes/changes an API) refactor Reorganizes code with no changes to the API or functionality in the main library or other benefits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants