Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/AlertPresentable/AlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class AlertController {
/// On tap, close the alert.
///
public static var no: Self {
.init(label: String(localized: String.LocalizationValue("no"), bundle: .module))
.init(label: String(localized: String.LocalizationValue("no"), bundle: .module), role: .cancel)
}

///
Expand All @@ -103,7 +103,7 @@ public class AlertController {
/// - parameter action: The custom action which is fired when the button was tapped just before close the alert.
///
public static func no(action: @escaping () -> Void) -> Self {
.init(label: String(localized: String.LocalizationValue("no"), bundle: .module), action: action)
.init(label: String(localized: String.LocalizationValue("no"), bundle: .module), role: .cancel, action: action)
}

///
Expand Down
4 changes: 3 additions & 1 deletion Sources/AlertPresentable/View+Alert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ private struct CommonAlert: ViewModifier {
content
.alert(alertController.title, isPresented: $alertController.isPresented) {
ForEach(alertController.actions) { action in
Button(action.label, role: action.role) {
Button(role: action.role) {
if let action = action.action {
action()
return
}
alertController.isPresented = false
} label: {
Text(action.label)
}
}
} message: {
Expand Down