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

Bug Fix empty html useless added by PR #1123 / v1.2.0 #1158

Merged
merged 15 commits into from
Mar 5, 2019

Conversation

pieplu
Copy link
Contributor

@pieplu pieplu commented Jan 28, 2019

Reasons for making this change

The merged PR #1123 add useless wrapping html tag (with empty className) for all field, even if they are no additonal field. This PR fix this.
See comment: #1123 (comment)

Some points:

  • I add new cssClass form-additional-* to help targeting (like for array field)
  • I use col-9 and 3, like array field, and I don't put on the same line the "Key" field and the "value" field by default. It's unusable on small screen. I think it will be the job of the integrator to add css rules to put this on the same line, if needed.
  • Maybe it will be good a day to found an other solution for the "key" label name, its really not internationalizable...

Checklist

  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style

@pieplu
Copy link
Contributor Author

pieplu commented Jan 28, 2019

@aerfio are you agree with this change?

@aerfio
Copy link
Contributor

aerfio commented Jan 28, 2019

@pieplu I'm just a contributor, not a codeowner, so you don't have to ask for my agreement 😛

image
But personally I think delete button shouldn't end in 4/5 of width, it would be nice if that blank space on the right side was filled

I don't know if you can do what I proposed in bootstrap3, but you can certainly do that using flex; I don't know what is the final stance of codeowners considering this matter - it is used here btw: https://github.com/mozilla-services/react-jsonschema-form/blob/174e136af4fe728eb79e92594733ea729f3d659f/src/components/fields/ArrayField.js#L59

@pieplu pieplu changed the title Fix empty html useless added by PR #1123 Bug Fix empty html useless added by PR #1123 Feb 4, 2019
@pieplu
Copy link
Contributor Author

pieplu commented Feb 4, 2019

@aerfio It's because it's a change on your contribution.

For the blank space, I think it's not a real problem. It's not the best visual, but we are limited on bootstrap style.
Dev's can esealy overwrite css to style this.
I thinks it's better than apply a style on a DOM node, because it's realy harder to overwrite, I agree with @glasserc position. On the ArrayField I think it's a technical depth.

Maybe a good option for inline-style, will be to have an api to overwrite the inline-style object, like react-select do.

@pieplu pieplu changed the title Bug Fix empty html useless added by PR #1123 Bug Fix empty html useless added by PR #1123 / v1.2.0 Feb 6, 2019
@epicfaace
Copy link
Member

@pieplu Could you please modify this PR not to use the WrapIfAdditional component? That way it will be easier to see what logic exactly you are changing. Thanks!

@pieplu
Copy link
Contributor Author

pieplu commented Feb 11, 2019

I push it, but I don't think it will be better. It will insert code duplication. It's a big risk of bugs for all future editing of the component.

The reason why I add WrapIfAdditionals Component is to be more understandable. But maybe I lost it.

I will try to explain it:

SchemaFields.js part, before the "additional properties feature":

<div className={classNames}>
     {displayLabel && <Label label={label} required={required} id={id} />}	
      {displayLabel && description ? description : null}	
      {children}	
      {errors}	
      {help}	
  </div>

Html output:
image

PR #1021 and #1123 added some code around that to support the additional properties feature.
The big problem, since v1.2.0, for ALL fields (even if no additional properties), looks like this:

image

To be able to support additional properties feature, it will be important to wrap the schema field with some div. It's the problem, the level of complexity had grown up, and if we preserved same render for all other fields, the wrapping div should not be present any time.

Maybe a better solution will be to introduce a new field component (like ArrayFieldDo) ?

@epicfaace
Copy link
Member

@pieplu , thanks for the explanation, I see what you're doing now. To remove code duplication, you could store the duplicated code in a variable as shown here: https://stackoverflow.com/a/33710901

Also, can you please include only the changes that fix the wrapping div's and the col-xs-12 div in this PR? I appreciate the other changes you made, but I think it's best if those are made on another PR so there is a chance to examine and discuss those changes separately. 👍

@pieplu
Copy link
Contributor Author

pieplu commented Feb 11, 2019

@epicfaace Good point for the other PR. +1
For your suggestion, I will, try, but I don't think it will works, because it's not one React node, but many. And on React 15 we don't have React.Fragment built-in.

@epicfaace
Copy link
Member

epicfaace commented Feb 18, 2019

@pieplu sounds good, please make that other PR!

And, yes, I see your point for using WrapIfAdditional now. Once you separate the additional changes made to the other PR, then the diff will be cleaner even with the WrapIfAdditional component. Thanks for sticking with this! 😄

@epicfaace
Copy link
Member

@pieplu just a reminder to make the PR when you get a chance! I'd like to start merging your changes.

@pieplu
Copy link
Contributor Author

pieplu commented Feb 26, 2019 via email

@pieplu
Copy link
Contributor Author

pieplu commented Feb 28, 2019

@epicfaace done!

I will make an other PR with CSS className change for easy customisation

Copy link
Member

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

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

One more thing. I believe you don't need parentProps, so the way I suggested might be cleaner.

src/components/fields/SchemaField.js Outdated Show resolved Hide resolved
src/components/fields/SchemaField.js Outdated Show resolved Hide resolved
@pieplu
Copy link
Contributor Author

pieplu commented Mar 5, 2019

@epicfaace Done!

test/ObjectField_test.js Outdated Show resolved Hide resolved
@pieplu
Copy link
Contributor Author

pieplu commented Mar 5, 2019

@epicfaace re Done!

@epicfaace
Copy link
Member

Great! It looks good. Thanks for the good work!

@epicfaace epicfaace merged commit 10a6b64 into rjsf-team:master Mar 5, 2019
CodeGains pushed a commit to CodeGains/react-jsonschema-form that referenced this pull request Mar 5, 2019
…team#1158)

* Infer type from enum if a type is not provided to SelectWidget (rjsf-team#1100)

Connects to rjsf-team#1098

Change-type: minor
Signed-off-by: Lucian <lucian.buzzo@gmail.com>

* No more useless div on schema field not additional

* Fix tests (remove useles html)
- Revert some test added by
https://github.com/mozilla-services/react-jsonschema-form/pull/1123/files
- use new css class for form-additional insted layout css class
for test selection

* Don't use WrapIfAdditonal Component to hav a clerer diff, but adding code duplicate

* Use a WrapIfAdditional Component to have a cleanner code / diff

* Fix tests

* Ignore vscode Ide folder

* Remove useless parentProps

* Fix old test selector for form additional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants