-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Hide grid for hidden fields (material-ui, bootstrap-4, fluent-ui); pass hidden prop to ObjectFieldTemplate #2405
Merged
epicfaace
merged 12 commits into
rjsf-team:master
from
Fox32:feat/fix-hidden-material-ui
Jun 15, 2021
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bc2d8bc
material-ui: hide grid for hidden fields
Fox32 d88df9b
Merge branch 'master' into feat/fix-hidden-material-ui
Fox32 e1dcec6
Merge branch 'master' into feat/fix-hidden-material-ui
Fox32 2a01aee
Update test snapshot to latest master
Fox32 42095ca
Merge branch 'master' into feat/fix-hidden-material-ui
Fox32 83adf05
Add comment
Fox32 0a69f63
Move ui:widget evaluation into core
Fox32 f8c79ec
Add test for hidden in antd
Fox32 37a74e7
Hide hidden fields in bootstrap
Fox32 15063e8
Improve tests
Fox32 a089c74
Remove whitespace for hidden in fluent-ui
Fox32 edab596
Update custom-templates.md
epicfaace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need this change in ObjectFieldTemplate -- what does it do? Isn't the FieldTemplate change enough?
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.
Here (
ObjectFieldTemplate
) a<Grid>
with a margin is added, which means that a hidden element would still take up space. We have to remove the<Grid>
if the field is hidden.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 you think the code needs a comment to explain this?
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.
Oh, I see. Instead of doing this, could we check if
element.content === null
and then remove the grid? I'm asking because it's currently possible to specify widgets in different ways thanui:widget
(we can do{'ui:options': {'widget': ...
) so it's good not to tie the implementation specifically toui:widget
.Can you also add a comment describing why we're hiding the grid in this case?
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.
hmm
element.content === null
is nottrue
in that case. There is still a field create, just a hidden one. Is there any other way I can use to support both cases without having to hard code it in that spot?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.
But in that case they would both evaluate the same condition: https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/fields/SchemaField.js#L307
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.
Yeah, good point.
I wonder if we could still pass the
hidden
prop over to ObjectFieldTemplate from@rjsf/core
, though, as this would reduce code duplication with checking ui:widget. How feasible / easy do you think that change would be?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.
Doing this would also help out with #2175! (similar issue with bootstrap-4 theme)
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.
Had some trouble with
nanoid
, but I think I got it working now. Still have to postpone it till tomorrow.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.
PR is updated. I couldn't find a good place in
core
to test it, so I skipped that. I replaced the old implementation inantd
. I also went through all themes and fixed #2175 for bootstrap-4 and fluid-ui.