@@ -49,10 +49,6 @@ const NAME_VALIDATIONS = {
4949 regex : / ^ (? ! .* \s \s ) .* $ / ,
5050 message : 'Name cannot contain consecutive spaces.' ,
5151 } ,
52- noLeadingTrailingSpaces : {
53- test : ( value : string ) => value === value . trim ( ) ,
54- message : 'Name cannot start or end with spaces.' ,
55- } ,
5652}
5753
5854const validateEmailField = ( emailValue : string ) : string [ ] => {
@@ -175,10 +171,6 @@ function SignupFormContent({
175171 errors . push ( NAME_VALIDATIONS . noConsecutiveSpaces . message )
176172 }
177173
178- if ( ! NAME_VALIDATIONS . noLeadingTrailingSpaces . test ( nameValue ) ) {
179- errors . push ( NAME_VALIDATIONS . noLeadingTrailingSpaces . message )
180- }
181-
182174 return errors
183175 }
184176
@@ -193,11 +185,10 @@ function SignupFormContent({
193185 }
194186
195187 const handleNameChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
196- const newName = e . target . value
197- setName ( newName )
188+ const rawValue = e . target . value
189+ setName ( rawValue )
198190
199- // Silently validate but don't show errors until submit
200- const errors = validateName ( newName )
191+ const errors = validateName ( rawValue )
201192 setNameErrors ( errors )
202193 setShowNameValidationError ( false )
203194 }
@@ -224,23 +215,21 @@ function SignupFormContent({
224215 const formData = new FormData ( e . currentTarget )
225216 const emailValue = formData . get ( 'email' ) as string
226217 const passwordValue = formData . get ( 'password' ) as string
227- const name = formData . get ( 'name' ) as string
218+ const nameValue = formData . get ( 'name' ) as string
219+
220+ const trimmedName = nameValue . trim ( )
228221
229- // Validate name on submit
230- const nameValidationErrors = validateName ( name )
222+ const nameValidationErrors = validateName ( trimmedName )
231223 setNameErrors ( nameValidationErrors )
232224 setShowNameValidationError ( nameValidationErrors . length > 0 )
233225
234- // Validate email on submit
235226 const emailValidationErrors = validateEmailField ( emailValue )
236227 setEmailErrors ( emailValidationErrors )
237228 setShowEmailValidationError ( emailValidationErrors . length > 0 )
238229
239- // Validate password on submit
240230 const errors = validatePassword ( passwordValue )
241231 setPasswordErrors ( errors )
242232
243- // Only show validation errors if there are any
244233 setShowValidationError ( errors . length > 0 )
245234
246235 try {
@@ -249,7 +238,6 @@ function SignupFormContent({
249238 emailValidationErrors . length > 0 ||
250239 errors . length > 0
251240 ) {
252- // Prioritize name errors first, then email errors, then password errors
253241 if ( nameValidationErrors . length > 0 ) {
254242 setNameErrors ( [ nameValidationErrors [ 0 ] ] )
255243 setShowNameValidationError ( true )
@@ -266,8 +254,6 @@ function SignupFormContent({
266254 return
267255 }
268256
269- // Check if name will be truncated and warn user
270- const trimmedName = name . trim ( )
271257 if ( trimmedName . length > 100 ) {
272258 setNameErrors ( [ 'Name will be truncated to 100 characters. Please shorten your name.' ] )
273259 setShowNameValidationError ( true )
@@ -337,7 +323,6 @@ function SignupFormContent({
337323 logger . info ( 'Session refreshed after successful signup' )
338324 } catch ( sessionError ) {
339325 logger . error ( 'Failed to refresh session after signup:' , sessionError )
340- // Continue anyway - the verification flow will handle this
341326 }
342327
343328 // For new signups, always require verification
0 commit comments