Apply accessibility labels to MenuPicker actions

This commit is contained in:
Shadowfacts 2023-02-13 20:27:05 -05:00
parent 4731801893
commit f833bc3a6f
1 changed files with 3 additions and 1 deletions

View File

@ -39,9 +39,11 @@ struct MenuPicker<Value: Hashable>: UIViewRepresentable {
} }
button.configuration = config button.configuration = config
button.menu = UIMenu(children: options.map { opt in button.menu = UIMenu(children: options.map { opt in
UIAction(title: opt.title, subtitle: opt.subtitle, image: opt.image, state: opt.value == selection ? .on : .off) { _ in let action = UIAction(title: opt.title, subtitle: opt.subtitle, image: opt.image, state: opt.value == selection ? .on : .off) { _ in
selection = opt.value selection = opt.value
} }
action.accessibilityLabel = opt.accessibilityLabel
return action
}) })
button.accessibilityLabel = selectedOption.accessibilityLabel ?? selectedOption.title button.accessibilityLabel = selectedOption.accessibilityLabel ?? selectedOption.title
button.isPointerInteractionEnabled = buttonStyle == .iconOnly button.isPointerInteractionEnabled = buttonStyle == .iconOnly