Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Input fields to have expected behaviour in case of empty / only whitespaces string #6736

Merged
merged 31 commits into from
Sep 20, 2024

Conversation

Nabhag8848
Copy link
Contributor

@Nabhag8848 Nabhag8848 commented Aug 26, 2024

ISSUE

Description

  • Don't allow Empty (whitespaces) Objects to Create, all the keyboard shortcuts are also handled for this.
Screen.Recording.2024-08-27.at.10.21.21.AM.mov
Screen.Recording.2024-08-30.at.2.57.45.PM.mov

Note: we do have one other issue with FullName field #6740 Inorder to test use shift.

  • Api Keys Input Name Field -> New and Detail View Name field shouldn't be empty or string with whitespaces, we won't able to have whitespaces in both. Try Entering just spaces
Screen.Recording.2024-08-27.at.10.28.13.AM.mov
  • Similar to above, Empty webhook endpoint url under /settings/developers/webhooks/new won't be created. Try Entering just spaces

  • New Functions or Updating Functions will not able to have whitespaces, empty string as Name. Try Entering just spaces

Screen.Recording.2024-08-27.at.10.31.07.AM.mov
  • under settings/workspace-members changes will lead and solve that user won't be able to enter Invite by email as just whitespaces + button is now getting disabled when there is no correct email. Try Entering just spaces
Screen.Recording.2024-08-27.at.10.33.18.AM.mov
  • Text Input Field, will not allow to start entering with whitespaces and won't take just whitespaces as value spaces between words will work.
Screen.Recording.2024-08-30.at.2.47.02.PM.mov
  • Similarly Number works as per above including shortcuts.
Screen.Recording.2024-08-30.at.2.48.07.PM.mov
  • Similarly FullName field works as per above including shortcuts
Screen.Recording.2024-08-30.at.2.56.26.PM.mov
  • Pasting fullName is been Improved.

  • Case 1 (Two Words): If there are exactly two words, return them as is.

  • Case 2 (More than Two Words): If there are more than two words, return the first two words only.

  • Case 3 (One Word): If there is only one word, return it as the first name, with an empty string as the last name.

  • WhiteSpaces have been handled.

console.log(splitFullName("John     Doe")); // ["John", "Doe"]
console.log(splitFullName("        ")); // ["", ""]
console.log(splitFullName("John")); // ["John", ""]
console.log(splitFullName("  John   Doe  ")); // ["John", "Doe"]
console.log(splitFullName("John Michael  Andrew Doe")); // ["John", "Michael"]

@Nabhag8848 Nabhag8848 changed the title fix: empty string draftvalue doesn't resetting to undefined fix: text input field to not create in case of empty / only whitespaces string Aug 26, 2024
@Nabhag8848 Nabhag8848 changed the title fix: text input field to not create in case of empty / only whitespaces string fix: text input field to have expected behaviour in case of empty / only whitespaces string Aug 26, 2024
@Nabhag8848 Nabhag8848 marked this pull request as ready for review August 26, 2024 14:49
@Nabhag8848 Nabhag8848 changed the title fix: text input field to have expected behaviour in case of empty / only whitespaces string fix: Input field to have expected behaviour in case of empty / only whitespaces string Aug 26, 2024
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request addresses issues with whitespace handling and empty input validation across various components in the Twenty application. Here's a concise summary of the key changes:

  • Implemented convertToEmptyStringForWhitespaces utility function to handle whitespace-only inputs
  • Modified input handling in EmailFieldInput, FullNameFieldInput, and TextFieldInput components
  • Updated API key and serverless function creation/editing to prevent empty or whitespace-only names
  • Improved WorkspaceInviteTeam component to disable submit button for invalid email inputs
  • Enhanced TextInputV2 component to handle whitespace-only inputs consistently
  • Added convertToUndefinedForWhitespaces utility for converting whitespace to undefined in certain scenarios

These changes collectively prevent the creation of empty objects and improve input validation throughout the application, addressing the issues mentioned in #6734 and #6633.

12 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings

@Nabhag8848 Nabhag8848 changed the title fix: Input field to have expected behaviour in case of empty / only whitespaces string fix: Input fields to have expected behaviour in case of empty / only whitespaces string Aug 26, 2024
@Nabhag8848 Nabhag8848 marked this pull request as draft August 27, 2024 06:20
@Nabhag8848 Nabhag8848 marked this pull request as ready for review August 30, 2024 07:53
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

This pull request continues to address issues with whitespace handling and empty input validation across various components in the Twenty application. Here's a summary of the recent changes:

  • Modified NumberFieldInput to properly handle empty or whitespace-only inputs, preventing unexpected behavior with null or undefined values.
  • Updated FullNameFieldInput to simplify code and improve whitespace handling in name inputs.
  • Changed FieldNumberDraftValue type from string to number in FieldInputDraftValue.ts, improving type safety for number fields.
  • Implemented NameField component for updating workspace display names, including a check to prevent empty name updates.
  • Modified DoubleTextInput and TextInput components to trim whitespace from pasted and input values, addressing issues with empty or whitespace-only content.
  • Updated TextAreaInput to use the new convertToEmptyStringForWhitespaces utility function for consistent whitespace handling.

These changes further improve input validation and whitespace handling throughout the application, addressing the issues mentioned in #6734, #6633, and #6733.

15 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings

@Nabhag8848
Copy link
Contributor Author

@lucasbordeau ready for review. 🚀

@Nabhag8848
Copy link
Contributor Author

@charlesBochet solved merge conflicts 🙏🏻

@lucasbordeau lucasbordeau merged commit c97c717 into twentyhq:main Sep 20, 2024
9 of 11 checks passed
Copy link

Thanks @Nabhag8848 for your contribution!
This marks your 14th PR on the repo. You're top 2% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants