rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
14.3k stars 2.19k forks source link

Material UI Select widget label always shrinked #3369

Closed ValYouW closed 1 year ago

ValYouW commented 1 year ago

The SelectWidget always uses a shrinked label: https://github.com/rjsf-team/react-jsonschema-form/blob/v5.0.0-beta.16/packages/material-ui/src/SelectWidget/SelectWidget.tsx#L67

The shrink property should be dependent on the current value, whether it is empty or not

I can provide a PR if it make sense.

heath-freenome commented 1 year ago

@ValYouW Yes, any help is encouraged! If you do fix it, please also update the @rjsf/mui package as well since the code is essentially the same. Thanks!

ValYouW commented 1 year ago

ok. I have forked the repo and trying to build validator-ajv8 I get this error, any idea? I just forked, npm install, and trying to build... (I built utils/core/mui successfully but can't run the tests without validator-ajv8)

(typescript) Error: D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/src/createAjvInstance.ts(45,16): semantic error TS2345: Argument of type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/ajv").default' is not assignable to parameter of type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/core").default'.
  Types of property 'opts' are incompatible.
    Type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/core").InstanceOptions' is not assignable to type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/core").InstanceOptions'.
      Type 'InstanceOptions' is not assignable to type 'CurrentOptions'.
        Types of property 'keywords' are incompatible.
          Type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/types/index").Vocabulary | undefined' is not assignable to type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/types/index").Vocabulary | undefined'.
            Type 'Vocabulary' is not assignable to type '(string | KeywordDefinition)[]'.
              Type 'string | import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/types/index").KeywordDefinition' is not assignable to type 'string | import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/types/index").KeywordDefinition'.
                Type 'CodeKeywordDefinition' is not assignable to type 'string | KeywordDefinition'.
                  Type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/types/index").CodeKeywordDefinition' is not assignable to type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/types/index").CodeKeywordDefinition'.
                    Types of property 'code' are incompatible.
                      Type '(cxt: import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/compile/validate/index").KeywordCxt, ruleType?: string | undefined) => void' is not assignable to type '(cxt: import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/compile/validate/index").KeywordCxt, ruleType?: string | undefined) => void'.
                        Types of parameters 'cxt' and 'cxt' are incompatible.
                          Type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/compile/validate/index").KeywordCxt' is not assignable to type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/compile/validate/index").KeywordCxt'.
                            The types of 'gen._scope' are incompatible between these types.
                              Type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv/dist/compile/codegen/scope").Scope' is not assignable to type 'import("D:/MyProjects/react-jsonschema-form/packages/validator-ajv8/node_modules/ajv8/dist/compile/codegen/scope").Scope'.
                                Property '_names' is protected but type 'Scope' is not a class derived from 'Scope'.
heath-freenome commented 1 year ago

Interesting that you are seeing that when others have not. What version of node are you running. Also, we are removing the ajv8 alias in a pending PR #3371 so hopefully when that merges in the next day or so this issue goes away.

ValYouW commented 1 year ago

I'm still on node 14 (old projects that I need to support). Weird indeed...

ValYouW commented 1 year ago

Just an update: After running npm install I've noticed that package-lock.json has been updated, so I deleted my node_modules, revert package-lock.json changes and ran npm ci - now it builds successfully. It seems like a minor change to ajv is breaking it...