Repository navigation
feat(ui)!: passes field props to custom components - #7360
Merged
Merged
Conversation
Contributor
|
@jacobsfletch nice! Does this mean on custom |
Member
Author
You got it 👍 field props will now be provided to all |
jacobsfletch
requested review from
AlessioGr,
denolfe and
jmikrut
as code owners
July 25, 2024 16:17
Member
|
Looks like we neeed to get a few tests ironed out on this one yet, right? |
Member
Author
I've written a few tests for this already, do you mean more tests, or passing tests? |
jacobsfletch
enabled auto-merge (squash)
July 26, 2024 17:55
jacobsfletch
disabled auto-merge
July 26, 2024 18:02
This was referenced Jul 26, 2024
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Currently, there is no way to read field props from within a custom field component, i.e.
admin.components.Description. For example, if you setmaxLength: 100on your field, your custom description component cannot read it fromprops.maxLengthor any other methods. Because these components are rendered on the server, there is also no way of usingadmin.component.Fieldto inject custom props yourself, either. To support this, we can simply pass the base component props into these components on the server, as expected. This has also led to custom field component props becoming more strictly typed within the config.This change is considered breaking only because the types have changed. This only affects you if you were previously importing the following types into your own custom components. To migrate, simply change the import paths for that type.
Old:
New:
Custom field components are now much more strongly typed. To make this happen, an explicit type for every custom component has been generated for every field type. The convention is to append
DescriptionComponent,LabelComponent, andErrorComponentonto the end of the field name, i.e.TextFieldDescriptionComponent. Here's an example:Here's the full list of all new types:
Label Components:
Error Components:
Description Components:
This PR also:
Standardizes the
FieldBase['label']type with a newLabelStatictype. This makes type usage much more consistent across components.Simplifies some of the typings in the field component map, removes unneeded
<Omit>, etc.Fixes misc. linting issues around voiding promises
I have read and understand the CONTRIBUTING.md document in this repository.
Type of change
Checklist: