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

React material table cell validationMode #2400

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

0mpurdy
Copy link

@0mpurdy 0mpurdy commented Nov 29, 2024

Fix #2398

@CLAassistant
Copy link

CLAassistant commented Nov 29, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

netlify bot commented Nov 29, 2024

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 0038727
🔍 Latest deploy log https://app.netlify.com/sites/jsonforms-examples/deploys/67509bc14e02b8000820a868
😎 Deploy Preview https://deploy-preview-2400--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@0mpurdy
Copy link
Author

0mpurdy commented Nov 29, 2024

Before After
before after

);
const messageFormHelperText = wrapper.find(FormHelperText).at(0);
expect(messageFormHelperText.text()).toBe(
"must have required property 'message'"
Copy link
Author

Choose a reason for hiding this comment

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

@sdirix Thought I'd at least attempt to add relevant unit tests - there didn't seem to be any for MaterialTableControl

This fails - not sure if validation just doesn't run for some reason

If you know why let me know and I'll fix it, otherwise I can either skip this test, or remove this file all together.

Testing manually with the examples seems to be working as expected

Copy link
Author

Choose a reason for hiding this comment

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

Interestingly, the test works with message: { type: 'string', minLength: 3 }

So that's another option, but doesn't really explain why required is not being calculated correctly in this context

Copy link
Contributor

Choose a reason for hiding this comment

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

In the unit test, did you add the required property as an empty string or leave out the property completely?
If it's empty, the required check does not fail. In the ui, the renderer unsets the field to undefined when it is empty. That could be a reason for different results.

I also tested it in the example app and there showing the required error on an array item still worked fine (I locally extended the arrays.ts example for this).

Could you re-add a unit test for this? If it still doesn't run as expected, I can have a look then :)

Copy link
Author

Choose a reason for hiding this comment

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

You're absolutely right, I've added more test cases to reflect this

@lucas-koehler
Copy link
Contributor

@0mpurdy Thanks for the contribution ❤️
The changes already look quite good to me. Please have a look at my answer to your comment #2400 (comment)

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.

ValidateAndHide only partially working for react material table cell
3 participants