-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[$500] PR 27825 RM - Save button should remain disabled until something is entered in the input field. #27998
Comments
Triggered auto assignment to @greg-schroeder ( |
Bug0 Triage Checklist (Main S/O)
|
Found when validating PR : #27825 |
ProposalPlease re-state the problem that we are trying to solve in this issue.Save button should remain disabled until something is entered in the input field What is the root cause of that problem?We don't have any validation in case the waypointValue is empty App/src/pages/iou/WaypointEditor.js Line 106 in 603dc58
What changes do you think we should make in order to solve the problem?We can add validation like this
If we want to apply this validation only for start point and finish point we can add condition like this
Result |
### Proposal Please re-state the problem that we are trying to solve in this issue. What is the root cause of that problem? What changes do you think we should make in order to solve the problem? |
Job added to Upwork: https://www.upwork.com/jobs/~01153f7357f12f779a |
Triggered auto assignment to @johncschuster ( |
Applying |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Save button should remain disabled until something is entered in the input field. What is the root cause of that problem?No validation is made on the input field. What changes do you think we should make in order to solve the problem?Have the disabled status of the save button updated based on the input field, having it disabled when it's empty. |
📣 @RobertAndreiGit! 📣
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
ProposalPlease re-state the problem that we are trying to solve in this issue.Clicking Save on empty input returns to previous page What is the root cause of that problem?The App/src/pages/iou/WaypointEditor.js Lines 134 to 136 in f068ef1
and the The above are the RCE for this problem. What changes do you think we should make in order to solve the problem?Just add a condition App/src/pages/iou/WaypointEditor.js Lines 113 to 115 in f068ef1
However, this will not disable the Still if need to disable the button if input empty, we can pass a prop down the component and add a condition to disable the button. What alternative solution do you find?As stated in another proposal, we can handle this condition generically throughout the app by handling it within the form component it self. |
Using hooks we can able to solve the issue easily in React js. useState you have to use If we create a button, it is enable by default. For disabling the button, we have to pass disabled={state}. Based on your Query, we have to call a arrow function for the on-change function of input field, here event will trigger, when we enter something. So, here we have to write a if condition inside of the function was, if event has some length, only then updatedState should be set as false. Then the state value will hits to button disabled mode. Initially the state was set as true, but if we enter something in input field, then the event has some length, then the updatedState is setting as false in input field on-change function. So, based on your requirement, the save button, will only be enable, when we enter something on input field, until it will be disable mode only. Hope you understand and the solution I have wrote will work definitely. Thank You....... |
📣 @Mounika-Donga! 📣
|
With the implementation of React hooks, we can streamline the process of managing form inputs and button states. This solution is designed to resolve the issue seamlessly. Here's a brief overview:
const [state, updateState] = useState(true);
<button disabled={state}>Submit</button>
<input type="text" onChange={handleChange} /> Inside this function, we'll include a conditional statement. If the input field has some content (i.e., its length is not zero), const handleChange = (e) => {
if (e.target.value.length > 0) {
updateState(false);
}
}; With this setup, the 'Submit' button will only be enabled when the input field contains some text. If the field is empty, the button will remain disabled. I hope this explanation is clear. I'm confident that this solution will effectively address the issue at hand. Thank you for considering this proposal. Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
ProposalPlease re-state the problem that we are trying to solve in this issue.The issue at hand pertains to the absence of error handling for empty or whitespace-only waypoint values. What is the root cause of that problem?The root cause of this problem is the absence of whitespace validation when assessing the waypointValue during the validation process. This deficiency is observed in the code at line 107 of the WaypointEditor App/src/pages/iou/WaypointEditor.js Lines 107 to 109 in 34e7377
What changes do you think we should make in order to solve the problem?As specified in Forms.md, form submit buttons shall not be disabled. So disabling the button is out of the question. I suggest we instead add
What alternative solutions did you explore? (Optional)NA |
📣 @zmaqutu! 📣
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
Looks like you've got this handled, @greg-schroeder. Unassigning myself! |
Fix: 4824d7f07fb24f73a98c940172bc2b69.mp4 |
I don't think the expected result is correct as we typically avoid disabling the submit button unless an API request is pending (see here). I think we're possibly expecting an error, but only in the case of there being only a start and end point (i.e. no intermediate stops), see this comment on the original PR. So in this video the behaviour is correct (no error), as we want to allow an empty address field as a way of deleting waypoints. Screen.Recording.2023-08-16.at.11.26.34.AM.movcc @thienlnam since you worked on the original waypoints PR, do you know/remember if it's expected to have an error if no address is entered (whilst online) and the save button is pressed? |
I'm closing this as it isn't a bug - you can save an empty waypoint to remove waypoints |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
If we don't enter anything atleast "Save" button should be disabled.
Actual Result:
App returns to the previous page when tap on the save button. Save button should remain disabled until something is entered in the input field.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: v1.3.72-6
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Bug6208917_27825_desktop.mp4
Expensify/Expensify Issue URL:
Issue reported by: Applause-Internal Team
Slack conversation: @
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: