Skip to content

Support Value pattern on editable ComboBox automation peer - #21545

Merged
MrJul merged 2 commits into
masterfrom
fix/editable-combobox-value-pattern
Jun 11, 2026
Merged

MrJul merged 2 commits into
masterfrom
fix/editable-combobox-value-pattern

Conversation

@jmacato

@jmacato jmacato commented Jun 11, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

Makes ComboBoxAutomationPeer expose the editable text through the Value pattern. Previously the peer hardcoded IsReadOnly => true, returned the selected item's name as Value, and threw from SetValue, so automation clients couldn't read or set the text of an editable ComboBox without reaching into the internal PART_EditableTextBox template part.

What is the updated/expected behavior with this PR?

For an editable ComboBox (IsEditable=true): IsReadOnly is false, Value returns Text, and SetValue sets Text. Non-editable ComboBoxes are unchanged (read-only, value is the selected item name). ValueProperty change notifications fire when Text changes, and IsReadOnlyProperty when IsEditable changes. Verified on macOS through the AX bridge: GetValue/SetValue on the ComboBox element read and write the editable text, with no native change needed.

How was the solution implemented (if it's not obvious)?

IValueProvider on the peer now branches on Owner.IsEditable, and OwnerPropertyChanged raises the value/read-only notifications. Six unit tests cover read-only state per editability, value get/set, the non-editable throw, and the change event.

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 updates ComboBoxAutomationPeer so editable ComboBox controls expose their editable text via the UI Automation Value pattern, allowing automation clients to read and set ComboBox.Text without accessing template parts.

Changes:

  • Implement IValueProvider behavior conditional on ComboBox.IsEditable (IsReadOnly, Value, and SetValue).
  • Raise automation property changed events when Text or IsEditable changes.
  • Add unit tests covering read-only behavior, value get/set, exception behavior, and value change notifications.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Avalonia.Controls/Automation/Peers/ComboBoxAutomationPeer.cs Implements Value pattern support for editable ComboBox and raises related automation property change events.
tests/Avalonia.Controls.UnitTests/Automation/ComboBoxAutomationPeerTests.cs Adds unit tests validating the new Value pattern behavior and event raising.

Comment thread src/Avalonia.Controls/Automation/Peers/ComboBoxAutomationPeer.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066253-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added enhancement area-accessibility backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels Jun 11, 2026

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrJul
MrJul added this pull request to the merge queue Jun 11, 2026
Merged via the queue into master with commit 905e620 Jun 11, 2026
12 checks passed
@MrJul
MrJul deleted the fix/editable-combobox-value-pattern branch June 11, 2026 16:17
MrJul pushed a commit to MrJul/Avalonia that referenced this pull request Jun 23, 2026
…I#21545)

* Support Value pattern on editable ComboBox automation peer

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@MrJul MrJul added backported-12.0.x and removed backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants