Skip to content

Commit 3a199d8

Browse files
SuthiYuvarajPureWeen
authored andcommitted
Fix VoiceOver doesnot announces the State of the ComboBox (#32286)
### Issue Description: VoiceOver does not read the ComboBox State correctly, In the sample, the ComboBox behavior is implemented using SfTextInputLayout with a Picker. However, I have already implemented the semantic properties for picker , it was overriden by SfTextInputLayout, the expectation is for VoiceOver to recognise and announce it as a ComboBox state. ### Description of change : Update SemanticProperties using property changed on IsOpen property in picker to achieve the expected output. > Note: net9.0 PR - dotnet/maui-samples#651 ### Issues Fixed Fixes [#30899 ](#30899) ### Tested the behaviour in the following platforms - [ ] Android - [ ] Windows - [ ] iOS - [x] Mac
1 parent b5d9d11 commit 3a199d8

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

src/Templates/src/templates/maui-mobile/PageModels/ProjectDetailPageModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public partial class ProjectDetailPageModel : ObservableObject, IQueryAttributab
4444
[ObservableProperty]
4545
bool _isBusy;
4646

47+
[ObservableProperty]
48+
private bool _isCategoryPickerExpanded;
49+
4750
[ObservableProperty]
4851
private List<IconData> _icons = new List<IconData>
4952
{
@@ -184,6 +187,18 @@ private async Task TaskCompleted(ProjectTask task)
184187
OnPropertyChanged(nameof(HasCompletedTasks));
185188
}
186189

190+
partial void OnIsCategoryPickerExpandedChanged(bool value)
191+
{
192+
if (value)
193+
{
194+
SemanticScreenReader.Announce("Category ComboBox, State Expanded");
195+
}
196+
else
197+
{
198+
SemanticScreenReader.Announce("Category ComboBox, State Collapsed");
199+
}
200+
}
201+
187202
[RelayCommand]
188203
private async Task Save()
189204
{

src/Templates/src/templates/maui-mobile/PageModels/TaskDetailPageModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public partial class TaskDetailPageModel : ObservableObject, IQueryAttributable
3434
[ObservableProperty]
3535
private bool _isExistingProject;
3636

37+
[ObservableProperty]
38+
private bool _isProjectPickerExpanded;
39+
3740
public TaskDetailPageModel(ProjectRepository projectRepository, TaskRepository taskRepository, ModalErrorHandler errorHandler)
3841
{
3942
_projectRepository = projectRepository;
@@ -118,6 +121,18 @@ public bool CanDelete
118121
}
119122
}
120123

124+
partial void OnIsProjectPickerExpandedChanged(bool value)
125+
{
126+
if (value)
127+
{
128+
SemanticScreenReader.Announce("Project ComboBox, State Expanded");
129+
}
130+
else
131+
{
132+
SemanticScreenReader.Announce("Project ComboBox, State Collapsed");
133+
}
134+
}
135+
121136
[RelayCommand]
122137
private async Task Save()
123138
{

src/Templates/src/templates/maui-mobile/Pages/ProjectDetailPage.xaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@
3636
Text="{Binding Description}" SemanticProperties.Description="Description" />
3737
</sf:SfTextInputLayout>
3838

39-
<sf:SfTextInputLayout
39+
<sf:SfTextInputLayout
4040
Hint="Category"
41-
SemanticProperties.Description="ComboBox to Select Category"
42-
SemanticProperties.Hint="State Collapsed">
43-
<Picker SemanticProperties.Hint="Select the category for the project"
44-
ItemsSource="{Binding Categories}"
41+
SemanticProperties.Description="ComboBox to select a category. Activate to browse and select a category">
42+
<Picker ItemsSource="{Binding Categories}"
4543
SelectedItem="{Binding Category}"
4644
SelectedIndex="{Binding CategoryIndex}"
47-
SemanticProperties.Description="Category State Expanded"/>
45+
IsOpen="{Binding IsCategoryPickerExpanded, Mode=TwoWay}"/>
4846
</sf:SfTextInputLayout>
4947

5048
<Label

src/Templates/src/templates/maui-mobile/Pages/TaskDetailPage.xaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,16 @@
3535
SemanticProperties.Hint="Indicates if this task is completed" />
3636
</sf:SfTextInputLayout>
3737

38-
<sf:SfTextInputLayout
38+
<sf:SfTextInputLayout
3939
IsVisible="{Binding IsExistingProject}"
40-
SemanticProperties.Description="ComboBox to select Project"
41-
SemanticProperties.Hint="State Collapsed"
40+
SemanticProperties.Description="ComboBox to select a project. Activate to browse and select a project"
4241
Hint="Project">
4342
<Picker
4443
ItemsSource="{Binding Projects}"
4544
ItemDisplayBinding="{Binding Name, x:DataType=models:Project}"
4645
SelectedItem="{Binding Project}"
4746
SelectedIndex="{Binding SelectedProjectIndex}"
48-
SemanticProperties.Description="Project State Expanded"
49-
SemanticProperties.Hint="Which project this task belongs to"/>
47+
IsOpen="{Binding IsProjectPickerExpanded, Mode=TwoWay}"/>
5048
</sf:SfTextInputLayout>
5149

5250
<Button

0 commit comments

Comments
 (0)