Skip to content

Fix ColorPicker selection when IsColorSpectrumVisible is false#866

Open
lgztx96 wants to merge 1 commit into
CommunityToolkit:mainfrom
lgztx96:fix/colorpicker-iscolorspectrumvisible
Open

Fix ColorPicker selection when IsColorSpectrumVisible is false#866
lgztx96 wants to merge 1 commit into
CommunityToolkit:mainfrom
lgztx96:fix/colorpicker-iscolorspectrumvisible

Conversation

@lgztx96

@lgztx96 lgztx96 commented Jun 28, 2026

Copy link
Copy Markdown

Fixes

#701

PR Type

What kind of change does this PR introduce?

Bugfix

What is the current behavior?

When ColorPicker.IsColorSpectrumVisible is set to False, the color spectrum panel can still become selected even though it is collapsed.

This happens because ColorPicker.ValidateSelectedPanel() correctly selects the first visible panel, but Segmented.OnApplyTemplate() later restores a stale SelectedIndex value from _internalSelectedIndex, causing the hidden spectrum panel to be selected again.

converted (2)

What is the new behavior?

ColorPicker now correctly respects IsColorSpectrumVisible, and hidden panels are no longer reselected.

The fix removes the default SelectedIndex="0" from the XAML template, preventing Segmented from caching an initial stale index in _internalSelectedIndex. This allows ValidateSelectedPanel() to preserve the correct visible selection.

converted (3)

PR Checklist

Please check if your PR fulfills the following requirements:

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • Tested code with current supported SDKs
    (https://github.com/CommunityToolkit/WindowsCommunityToolkit-design-assets)
  • Tests for the changes have been added (if applicable)
  • Header has been added to all new source files
  • Contains NO breaking changes

Other information

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.

1 participant