Trim value for text input when the input is blurred#144
Conversation
I think that's the way to go! |
|
@hanbyul-here thanks for the PR! 🎉
I agree as well :) - I think leading / trailing spaces can be transparently removed so they never reach the form. Or transparently removed just before attempting the form submission? Whichever way is easier, but yes, ideally they should be removed before it reaches the validation step. @hanbyul-here lemme know if it helps to quickly talk through. |
|
I pushed the change so the value gets trimmed when the input is blurred (when focus moves from the text input to somewhere else) ! |
|
@hanbyul-here this looks good to me. Am just slightly worried about some edge-cases where the Blur event does not trigger, but the user is still able to submit the form? Does it make sense to think about the doing the trim on form submission, so it's guaranteed to happen before validation triggers? But I can see there's two places - one when the user kicks off the image [1] build and one where the user submits the final form [2] , and it might get a bit weird to handle this in both places and then onBlur might be best. Am always just a bit worried that these |
|
Yah! that is a valid concern I also looked up before making this PR!
|
|
I made the mistake of pasting an image string with a trailing space again today. I'm so excited y'all are saving me from myself 😁 |
|
@hanbyul-here makes sense. I approved the PR and think it's fine to merge, but how do you feel about adding a test? I think it would be something in https://github.com/2i2c-org/jupyterhub-fancy-profiles/blob/main/src/ImageBuilder.test.tsx and / or https://github.com/2i2c-org/jupyterhub-fancy-profiles/blob/main/src/ProfileForm.test.tsx Might just also be a good way to familiarize with the testing workflow. |
This is to clean the value without access to onSubmit event of form
|
Thanks for your suggestion to put tests! I made a bit more changes than I initially made, also I realized that I don't know good values to test complete flows 💦 so I will appreciate if you can take one more look @batpad ! |
|
Yay, thank you @hanbyul-here 🎉 |
Close #143
I followed the suggestion from the ticket, but I wonder if it will be better to trim the value so leading/trailing slashes never reach to the form at all? 🤔