-
Notifications
You must be signed in to change notification settings - Fork 3
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
Disable save button if required fields are not populated #1505
Conversation
…on buttons and save is disabled until required fields are present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a reuseable component to be used in all our data grid tables for the action buttons
renderCell: ({ id }) => ( | ||
<DataGridActions | ||
id={id} | ||
requiredFields={["file_name", "file_url", "file_type"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do yall like this or do you want to define requiredFields elsewhere in a var somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels good to me. If I were to start a new table that needed an inline form, I could imagine this prop making me stop to consider what fields need are required as soon as i added this component.
I briefly thought about a way to tie to the column config but that feels like over-optimization at this point imo. None of these inline forms have a long list of required fields since we've tried to minimize side-scrolling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obligatory comment about non-stable object references: i think this is the slightest of anti-patterns versus declaring a const
outside of the component 😇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh yeah that is a great point, John! could you update @roseeichelmann?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome! I tested each table, and I don't see any regressions. I also see that saving on click-away is blocked when a required field is missing. 👍
Thank you for the level up on introspecting the grid state too. I added two questions, and requested one change outside the scope of this issue. This is ready to 🚢!
moped-editor/src/views/projects/projectView/ProjectFunding/ProjectFundingTable.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reusable component is so nice! ✨ Really cool to this common part of these tables extracted. 🧱
Also, thanks for matching this path up with the spot that Mateo began stashing DataGrid-related components. I know there are a lot of moving parts right now. 🙏
renderCell: ({ id }) => ( | ||
<DataGridActions | ||
id={id} | ||
requiredFields={["file_name", "file_url", "file_type"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels good to me. If I were to start a new table that needed an inline form, I could imagine this prop making me stop to consider what fields need are required as soon as i added this component.
I briefly thought about a way to tie to the column config but that feels like over-optimization at this point imo. None of these inline forms have a long list of required fields since we've tried to minimize side-scrolling.
moped-editor/src/views/projects/projectView/ProjectMilestones.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great - works perfect. Code looks good, but some of it is def above my pay grade. 🚢🚢🚢
I have one request -- and this is embarrassing -- I'm not sure how to nail down exactly where in the app this change needs to be made, but I figure y'all can real easy. Also - I'm pretty sure this behavior is not a result of this PR, so maybe this is a spin off thing, if y'all agree.
When I click on the cell, it gets this "focus" like behavior, and the enclosing cell gets this one pixel blue stroke around it that is out of place, imho. Like this:
This is the element, and it's this element that I'm struggling to point to in the application.
If you give that element a outline: none;
CSS property, it's fixed. I'm curious what you and @mddilley think. Thanks!!
@frankhereford thanks for the feedback! This is default styling and a feature of DataGridPro as seen in the CRUD example so I'd like to stick with the focus highlighting unless users have negative feedback about it. |
@mddilley wrote:
Sounds great to me. A last thought and forgive me, this is at the risk of feeling like i'm overly pushing back, but I don't mind the example you linked at all. I think it's the fact that we have a stroke around the cell, and a stroke around what's in the cell, and we have no padding separating the two. It becomes unusual looking to me because the hierarchy of what contains what is unclear. I guess my take is that like borders shouldn't abut onto other borders of the same style. In the screenshot above, I see a figure-8 of thin stroke, and is that a pair of cells next to each other or one containing the other? Being rhetorical here: Can I type in the second, smaller inpux box? Is that an input box, it kinda looks like one? Again - i'm super cool with sticking with it -- i just wanted to better explain my observation. Thank you for the super quick response!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff—I couldn't get anything done without filling in those required fields. Very nice UX upgrade here! 🚢 🚢 🚢 🚢
moped-editor/src/views/projects/projectView/ProjectMilestones.js
Outdated
Show resolved
Hide resolved
renderCell: ({ id }) => ( | ||
<DataGridActions | ||
id={id} | ||
requiredFields={["file_name", "file_url", "file_type"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obligatory comment about non-stable object references: i think this is the slightest of anti-patterns versus declaring a const
outside of the component 😇
} | ||
} | ||
return true; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very cool to see how this works and nice docstring 🙏
moped-editor/src/views/projects/projectView/ProjectFunding/ProjectFundingTable.js
Outdated
Show resolved
Hide resolved
@frankhereford thanks for expanding about the focus outline colliding with the input, and now I'm seeing it! 🔍 🙏 We have inconsistent spacing from table to table so I captured making it uniform in cityofaustin/atd-data-tech#20171 and cityofaustin/atd-data-tech#20213 for when we consolidate and make reusable components to use across the tables. |
@mddilley this is ready for re-review :)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New commits look great, and I retested with the latest changes. Thanks for updating!! 🚀🚀🚀
Associated issues
Closes cityofaustin/atd-data-tech#20084
This actually ended up being kinda weird to implement, i had to really dig thru github and stack overflow before i found out how to get the edited values while still in edit mode and cause a re-render to enable the save button. Finally I found this github issue where someone had the same problem and a rly helpful comment describing how to handle our use case with useGridSelector
Testing
URL to test:
https://deploy-preview-1505--atd-moped-main.netlify.app/moped/
Steps to test:
Ship list
Try to save a row without the Milestone column populated. You should see the Required helper text and input highlighted in red. The save button should also be disabled.
as a Milestones table test.