Skip to content

Add tests for CSS styles with IsEnabled=false - #32947

Merged
StephaneDelcroix merged 1 commit into
mainfrom
test/issue-12550-css-isenabled
Dec 2, 2025
Merged

StephaneDelcroix merged 1 commit into
mainfrom
test/issue-12550-css-isenabled

Conversation

@StephaneDelcroix

@StephaneDelcroix StephaneDelcroix commented Dec 1, 2025 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description

Adds unit tests for issue #12550 - CSS styles are ignored when element's IsEnabled=false on initialization.

Tests Added

  • XAML Unit Tests (Maui12550.xaml / .xaml.cs / .css):

    • CSSStyleAppliedToInitiallyEnabledButton - verifies CSS works on enabled buttons
    • CSSStyleAppliedAfterReEnablingInitiallyDisabledButton - verifies CSS is applied after re-enabling a button that started disabled
    • CSSStyleAppliedAfterDisableEnableCycle - verifies CSS is preserved through disable/enable cycle
  • Core Unit Test (StyleTests.cs):

    • CSSStyleAppliedAfterReEnablingInitiallyDisabledButton_Issue12550 - basic scenario test

Test Results

All tests pass, indicating the core CSS/VSM specificity logic is working correctly. The tests serve as regression tests to ensure this behavior continues to work.

Closes #12550

Copilot AI review requested due to automatic review settings December 1, 2025 20:53
@StephaneDelcroix StephaneDelcroix added this to the .NET 10.0 SR2 milestone Dec 1, 2025

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 adds comprehensive unit tests for issue #12550, which reported that CSS styles are ignored when an element's IsEnabled property is set to false during initialization. The tests verify that the core CSS/VSM specificity logic works correctly and serve as regression tests to ensure the behavior continues to function properly.

  • Adds XAML-based unit tests to verify CSS style application in various enabled/disabled scenarios
  • Adds a Core unit test for the basic reproduction case
  • All tests pass, indicating the issue is not present in the current codebase

Reviewed changes

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

File Description
src/Controls/tests/Xaml.UnitTests/Issues/Maui12550.xaml.cs Test code-behind with three test cases covering CSS application to enabled buttons, re-enabled buttons, and buttons cycled through enable/disable states
src/Controls/tests/Xaml.UnitTests/Issues/Maui12550.xaml XAML markup defining test page with two buttons (one initially disabled, one enabled) and CSS stylesheet reference
src/Controls/tests/Xaml.UnitTests/Issues/Maui12550.css Simple CSS stylesheet applying green background color to all buttons
src/Controls/tests/Core.UnitTests/StyleSheets/StyleTests.cs Core unit test for basic scenario of re-enabling an initially disabled button with CSS styling

@StephaneDelcroix
StephaneDelcroix merged commit b14c328 into main Dec 2, 2025
@StephaneDelcroix
StephaneDelcroix deleted the test/issue-12550-css-isenabled branch December 2, 2025 06:05
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSS styles are ignored when element's IsEnabled=false on initialization

2 participants