Skip to content

Commit b74a40d

Browse files
fix(email-verification): enhance error message handling in submission and input events
- Clear previous error messages when submitting the verification code, typing, or pasting input. - Improve user experience by ensuring error messages are reset appropriately during interactions. Jira Ticket: https://linuxfoundation.atlassian.net/browse/LFXV2-502 Generated with [Cursor](https://cursor.com/) Signed-off-by: Mauricio Zanetti Salomao <mauriciozanetti86@gmail.com>
1 parent fdfca42 commit b74a40d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

apps/lfx-one/src/app/modules/profile/email/email-verification-modal/email-verification-modal.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ export class EmailVerificationModalComponent implements OnInit, OnDestroy {
7676
}
7777

7878
public submitCode(): void {
79+
// Clear any previous error message first, before validation
80+
this.errorMessage.set(null);
81+
7982
if (this.verificationForm.invalid || this.submitting() || this.timerExpired()) {
8083
return;
8184
}
8285

83-
// Clear any previous error message
84-
this.errorMessage.set(null);
85-
8686
// Combine all 6 digits into a single code
8787
const code = `${this.verificationForm.value.digit1}${this.verificationForm.value.digit2}${this.verificationForm.value.digit3}${this.verificationForm.value.digit4}${this.verificationForm.value.digit5}${this.verificationForm.value.digit6}`;
8888
this.submitting.set(true);
@@ -139,6 +139,9 @@ export class EmailVerificationModalComponent implements OnInit, OnDestroy {
139139
const input = event.target as HTMLInputElement;
140140
const value = input.value;
141141

142+
// Clear any previous error message when user starts typing
143+
this.errorMessage.set(null);
144+
142145
// Check if this is a paste event (multiple characters)
143146
if (value.length > 1) {
144147
const digits = value.replace(/\D/g, '');
@@ -255,6 +258,9 @@ export class EmailVerificationModalComponent implements OnInit, OnDestroy {
255258
event.preventDefault();
256259
event.stopPropagation();
257260

261+
// Clear any previous error message when user pastes
262+
this.errorMessage.set(null);
263+
258264
const pastedData = event.clipboardData?.getData('text') || '';
259265
const digits = pastedData.replace(/\D/g, '').slice(0, 6);
260266

@@ -337,6 +343,9 @@ export class EmailVerificationModalComponent implements OnInit, OnDestroy {
337343
this.timerExpired.set(false);
338344
this.verificationForm.enable();
339345
this.verificationForm.reset();
346+
347+
// Clear any previous error message
348+
this.errorMessage.set(null);
340349

341350
// Restart the timer
342351
this.startTimer();

0 commit comments

Comments
 (0)