feat: restrict user to enter space in signup component input field#1107
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughInput sanitization logic added to the signup component's input handler. The onChange callback now strips all whitespace from the input value before passing it to the parent, and updates the event target's value accordingly. A potential runtime issue exists with event access. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
app/components/new-signup/input.js(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: MayankBansal12
Repo: Real-Dev-Squad/website-www PR: 1083
File: app/components/new-join-steps/new-step-one.hbs:47-56
Timestamp: 2025-11-08T13:14:05.646Z
Learning: In the Real-Dev-Squad/website-www repository onboarding form (app/components/new-join-steps/new-step-one.hbs), the fullName field is intentionally disabled as a product requirement. The name is picked from logged-in user data and users cannot change it during onboarding.
|
@azeemuddinaziz Please add unit tests for the change |
There was a problem hiding this comment.
Should we also add sanitization during the signup form submit for first and last name?
There was a problem hiding this comment.
There's no need to add sanitization on submit because it is guaranteed that no spaces will be present at submission time (already sanitized on input change).
There was a problem hiding this comment.
- what if user changes directly changes in HTML using inspect element?
- are there going to be any changes in backend API for this? how will API handle if spaces are included in names?
There was a problem hiding this comment.
-
Adding sanitization to the from button will be redundant. The user who bypasses the
onChangeinput sanitization by changing the value via browser dev tools will still ultimately receive an HTTP 400 Bad Request error response from the backend. -
No, there will be no changes in the backend API. It is already handling the input validation by using
validateGenerateUsernameQuerymiddleware.
There was a problem hiding this comment.
@azeemuddinaziz can you please reply to these question?
There was a problem hiding this comment.
@MayankBansal12 and @Suvidh-kaushik great observation, let me drill down this
In Ember (especially with tracked state + one-way data flow), direct DOM mutation can desync the input value from the tracked property backing that input.
What can go wrong
• Cursor jumps to the end while typing
• Value reverts on re-render
• Input appears to accept spaces briefly and then snaps back
• Fails when used with @value={{this.someTrackedProp}}
There was a problem hiding this comment.
@iamitprakash Thanks for detailed explanation.
- I added a
keydownevent thatpreventDefaultsspaces. This completely stops the cursor jumping and desync issues since the space never hits the DOM. - I still need the direct DOM manipulation for the paste edge case, where user directly pastes in a text which have spaces in it. I've updated it to only run if the input actually contains a space, so it won't interfere with normal updates.
There was a problem hiding this comment.
@azeemuddinaziz can you please reply to these question?
There was a problem hiding this comment.
-
Adding sanitization to the from button will be redundant. The user who bypasses the
onChangeinput sanitization by changing the value via browser dev tools will still ultimately receive an HTTP 400 Bad Request error response from the backend. -
No, there will be no changes in the backend API. It is already handling the input validation by using
validateGenerateUsernameQuerymiddleware.
- Sanitize input only when it contains a space.
…s incase of copy-paste text
- Group all whitespace related test under one module.
…ultiple positions
| } | ||
|
|
||
| @action inputFieldChanged({ target: { value } }) { | ||
| @action inputFieldChanged(event) { |
There was a problem hiding this comment.
I do see issue
When you remove whitespace and calculate the new cursor position, you're using:
javascriptconst newCursorPosition = Math.min(
nonWhitespaceBeforeCursor,
sanitizedInput.length,
);
But nonWhitespaceBeforeCursor is the count of non-whitespace characters, not accounting for the actual position in the sanitized string. This can cause the cursor to jump incorrectly.
The Bug Scenario:
If the user types: "abc def" with cursor after 'd' (position 5):
textBeforeCursor = "abc d"
nonWhitespaceBeforeCursor = 4 (correct)
But the sanitization happens on the entire input asynchronously
The real issue is that you're setting the value and cursor position synchronously, but the value update might not be immediate, causing cursor position issues.
There was a problem hiding this comment.
- The user cannot type "Space" in the input field.
- The DOM manipulation is only necessary if a user pastes text in the input directly.
- I still didn't completely understood the bug, because the final cursor position seems to be calculated correct.
19c1669
19c1669 to
b1615b1
Compare


Date:
15 Dec 2025Developer Name:
Azeemuddin AzizIssue Ticket Number:-
Description:
Previously, in the Signup Component's input field (
firstnameandlastname) users were able to add spaces in the input box. This PR implements to restrict users from adding any spaces in the input fields.Is Under Feature Flag
Database changes
Breaking changes (If your feature is breaking/missing something please mention pending tickets)
Is Development Tested?
Tested in staging?
Add relevant Screenshot below ( e.g test coverage etc. )
screencast
restrict-space-in-input.mov
tests