From 406516a3465820416b8ff765e70a88143d518924 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 24 Oct 2024 13:17:34 +0200 Subject: [PATCH] fix(email-checker): success can have no suggestions --- app/javascript/controllers/email_input_controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/controllers/email_input_controller.ts b/app/javascript/controllers/email_input_controller.ts index 31849ceaa..6a51cc2a2 100644 --- a/app/javascript/controllers/email_input_controller.ts +++ b/app/javascript/controllers/email_input_controller.ts @@ -4,7 +4,7 @@ import { ApplicationController } from './application_controller'; type CheckEmailResponse = | { success: true; - suggestions: string[]; + suggestions?: string[]; } | { success: false }; @@ -38,7 +38,7 @@ export class EmailInputController extends ApplicationController { .catch(() => null); if (data?.success) { - const suggestion = data.suggestions.at(0); + const suggestion = data.suggestions?.at(0); if (suggestion) { this.suggestionTarget.innerHTML = suggestion; show(this.ariaRegionTarget);