From 27bcc426e56b4fecb98627b0605e6425448d86b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bj=C3=B6rkert?= Date: Tue, 20 Oct 2026 20:23:55 +0200 Subject: [PATCH] Keep the guardrail alert visible on the carb and meal edit screens Tapping Update while the carb field is focused ran the guardrail check and then the form validation right after it. The guardrail alert reset the field to 0, so the validation replaced it with the empty-amount alert, or for a Trio meal with fat or protein, with the confirmation showing 0 g carbs. The validation now skips when an alert is already showing. --- LoopFollow/Remote/LoopAPNS/LoopCarbEditSheet.swift | 1 + LoopFollow/Remote/TRC/TRCMealEditView.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/LoopFollow/Remote/LoopAPNS/LoopCarbEditSheet.swift b/LoopFollow/Remote/LoopAPNS/LoopCarbEditSheet.swift index 2fd82cabc..fdf10c8f8 100644 --- a/LoopFollow/Remote/LoopAPNS/LoopCarbEditSheet.swift +++ b/LoopFollow/Remote/LoopAPNS/LoopCarbEditSheet.swift @@ -160,6 +160,7 @@ struct LoopCarbEditSheet: View { } private func validateAndConfirm() { + guard alertType == nil else { return } guard carbsAmount.doubleValue(for: .gram()) > 0 else { alertType = .validation("Enter a carb amount, or use Delete carbs to remove the entry.") return diff --git a/LoopFollow/Remote/TRC/TRCMealEditView.swift b/LoopFollow/Remote/TRC/TRCMealEditView.swift index 06cb8fa67..9da718162 100644 --- a/LoopFollow/Remote/TRC/TRCMealEditView.swift +++ b/LoopFollow/Remote/TRC/TRCMealEditView.swift @@ -90,6 +90,7 @@ struct TRCMealEditView: View { fatFocused = false proteinFocused = false DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + guard alertType == nil else { return } guard carbsValue > 0 || fatValue > 0 || proteinValue > 0 else { alertType = .validation("Enter at least one of carbs, fat, or protein. Use Delete meal to remove the meal.") return