Skip to content

Commit

Permalink
fix: 🐛 [IOSSDKBUG-448]FilterFeedbackBar accessibility id
Browse files Browse the repository at this point in the history
  • Loading branch information
restaurantt committed Nov 16, 2024
1 parent ffaac1a commit 989a6a5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct CancellableResettableDialogForm<Title: View, CancelAction: View, ResetAct
var body: some View {
VStack(spacing: UIDevice.current.userInterfaceIdiom != .phone ? 8 : 16) {
HStack {
self.cancelAction
self.cancelAction.accessibilityIdentifier("Cancel")
Spacer()
self.title
Spacer()
self.resetAction
self.resetAction.accessibilityIdentifier("Reset")
}
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)

Expand All @@ -42,6 +42,7 @@ struct CancellableResettableDialogForm<Title: View, CancelAction: View, ResetAct
self.components.background(Color.clear)
#endif
self.applyAction
.accessibilityIdentifier("Apply")
}
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.padding([.top, .bottom], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
Expand Down Expand Up @@ -84,17 +85,18 @@ struct CancellableResettableDialogNavigationForm<Title: View, CancelAction: View
self.components.background(Color.clear)
#endif
self.applyAction
.accessibilityIdentifier("Apply")
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
self.title
}
ToolbarItem(placement: .topBarLeading) {
self.cancelAction
self.cancelAction.accessibilityIdentifier("Cancel")
}
ToolbarItem(placement: .topBarTrailing) {
self.resetAction
self.resetAction.accessibilityIdentifier("Reset")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ extension SearchListPickerItem: View {
#endif
}
}
.accessibilityIdentifier(value)
.accessibilityElement(children: .combine)
}

private func selectionHeader() -> some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,34 @@ extension _SortFilterMenuItemContainer: View {
switch self._items[r][c] {
case .picker:
PickerMenuItem(item: Binding<SortFilterItem.PickerItem>(get: { self._items[r][c].picker }, set: { self._items[r][c].picker = $0 }), onUpdate: self.onUpdate)
.accessibilityElement()
.accessibilityLabel(self._items[r][c].picker.label)
.accessibilityIdentifier(self._items[r][c].picker.name)
case .filterfeedback:
FilterFeedbackMenuItem(item: Binding<SortFilterItem.PickerItem>(get: { self._items[r][c].filterfeedback }, set: { self._items[r][c].filterfeedback = $0 }), onUpdate: self.onUpdate)
.accessibilityElement()
.accessibilityLabel(self._items[r][c].filterfeedback.label)
.accessibilityIdentifier(self._items[r][c].filterfeedback.name)
case .switch:
SwitchMenuItem(item: Binding<SortFilterItem.SwitchItem>(get: { self._items[r][c].switch }, set: { self._items[r][c].switch = $0 }), onUpdate: self.onUpdate)
.accessibilityElement()
.accessibilityLabel(self.switchItemAccessibilityLabel(switchItem: self._items[r][c].switch))
.accessibilityIdentifier(self._items[r][c].switch.name)
case .slider:
SliderMenuItem(item: Binding<SortFilterItem.SliderItem>(get: { self._items[r][c].slider }, set: { self._items[r][c].slider = $0 }), onUpdate: self.onUpdate)
.accessibilityElement()
.accessibilityLabel(self._items[r][c].slider.label)
.accessibilityIdentifier(self._items[r][c].slider.name)
case .datetime:
DateTimeMenuItem(item: Binding<SortFilterItem.DateTimeItem>(get: { self._items[r][c].datetime }, set: { self._items[r][c].datetime = $0 }), onUpdate: self.onUpdate)
.accessibilityElement()
.accessibilityLabel(self._items[r][c].datetime.label)
.accessibilityIdentifier(self._items[r][c].datetime.name)
case .stepper:
StepperMenuItem(item: Binding<SortFilterItem.StepperItem>(get: { self._items[r][c].stepper }, set: { self._items[r][c].stepper = $0 }), onUpdate: self.onUpdate)
.accessibilityElement()
.accessibilityLabel(self._items[r][c].stepper.label)
.accessibilityIdentifier(self._items[r][c].stepper.name)
}
}
}
Expand All @@ -53,6 +71,16 @@ extension _SortFilterMenuItemContainer: View {
.frame(minHeight: 44)
.padding(.leading, 5)
}

private func switchItemAccessibilityLabel(switchItem: SortFilterItem.SwitchItem) -> String {
var accessibilityLabel = switchItem.name
if let value = switchItem.value {
accessibilityLabel += "\(value ? 1 : 0)"
} else {
accessibilityLabel += "\(0)"
}
return accessibilityLabel
}
}

struct SortFilterMenuItemFullConfigurationButtonKey: EnvironmentKey {
Expand Down

0 comments on commit 989a6a5

Please sign in to comment.