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

Disable save button if required fields are not populated #1505

Merged
merged 15 commits into from
Dec 12, 2024

Conversation

roseeichelmann
Copy link
Contributor

@roseeichelmann roseeichelmann commented Dec 10, 2024

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:

  1. On the project summary page, test adding a new subproject. The save button should be disabled until you select a project. Make sure the cancel and delete buttons work as well.
  2. Test all the other datagrid tables too, Milestones, Funding, and Files. If you dont have the required fields filled out then the save should be disabled. BTW Funding has no required fields.
  3. Test editing and deleting required fields, the save button should get disabled again.

Ship list

  • Code reviewed
  • Product manager approved
  • Product manager checked DB view dependencies
  • Product manager added to QA test script if applicable
    • Added 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.

@roseeichelmann roseeichelmann added the WIP Work in progress label Dec 10, 2024
Copy link
Contributor Author

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"]}
Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Member

@johnclary johnclary Dec 12, 2024

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 😇

Copy link
Collaborator

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?

@mddilley mddilley removed the WIP Work in progress label Dec 12, 2024
Copy link
Collaborator

@mddilley mddilley left a 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/components/DataGridPro/DataGridActions.js Outdated Show resolved Hide resolved
Copy link
Collaborator

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"]}
Copy link
Collaborator

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/components/DataGridPro/DataGridActions.js Outdated Show resolved Hide resolved
Copy link
Member

@frankhereford frankhereford left a 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:

image

This is the element, and it's this element that I'm struggling to point to in the application.

image

If you give that element a outline: none; CSS property, it's fixed. I'm curious what you and @mddilley think. Thanks!!

@mddilley
Copy link
Collaborator

@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.

@frankhereford
Copy link
Member

frankhereford commented Dec 12, 2024

@mddilley wrote:

This is default styling and a feature of DataGridPro

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!!

Copy link
Member

@johnclary johnclary left a 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! 🚢 🚢 🚢 🚢

renderCell: ({ id }) => (
<DataGridActions
id={id}
requiredFields={["file_name", "file_url", "file_type"]}
Copy link
Member

@johnclary johnclary Dec 12, 2024

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;
});
Copy link
Member

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 🙏

@mddilley
Copy link
Collaborator

@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.

@roseeichelmann
Copy link
Contributor Author

@mddilley this is ready for re-review :))

Copy link
Collaborator

@mddilley mddilley left a 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!! 🚀🚀🚀

@roseeichelmann roseeichelmann merged commit 597d76f into main Dec 12, 2024
4 checks passed
@roseeichelmann roseeichelmann deleted the rose/20084_datagrid_disable_save branch December 12, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable save button if required fields are not populated
4 participants