Merge pull request #10985 from tchak/fix-email-checker

fix(email-checker): success can have no suggestions
This commit is contained in:
LeSim 2024-10-25 09:05:13 +00:00 committed by GitHub
commit ee3ee8f78c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,7 +4,7 @@ import { ApplicationController } from './application_controller';
type CheckEmailResponse = type CheckEmailResponse =
| { | {
success: true; success: true;
suggestions: string[]; suggestions?: string[];
} }
| { success: false }; | { success: false };
@ -38,7 +38,7 @@ export class EmailInputController extends ApplicationController {
.catch(() => null); .catch(() => null);
if (data?.success) { if (data?.success) {
const suggestion = data.suggestions.at(0); const suggestion = data.suggestions?.at(0);
if (suggestion) { if (suggestion) {
this.suggestionTarget.innerHTML = suggestion; this.suggestionTarget.innerHTML = suggestion;
show(this.ariaRegionTarget); show(this.ariaRegionTarget);