-
Notifications
You must be signed in to change notification settings - Fork 1k
Add extend to formfield container based on child input kind #7498
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
Conversation
Children.forEach(children, (child) => { | ||
if (child && child.type) { | ||
childName = child.type.displayName; | ||
if (childName?.length > 1) |
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.
if (childName?.length > 1) | |
// camelCase component name to match theme object key | |
if (childName?.length > 1) |
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 check > 1?
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.
☝️ also was wondering the same thing. I guess Im assuming to ensure that only components with valid names but if we document this as working with only our inputs then Im not sure wed need the check?
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.
Switched this to > 0 instead of > 1
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.
Just wanted to check that the string wasn't ''
or undefined before trying to do childName.charAt(0).toLowerCase() + childName.slice(1)
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.
Behavior looking good here. The aesthetics of disabledProp
and componentName
feel a bit awkward to me, but I'm comfortable with the trade-off given it'll only be engaged with via extend
. Agree that this feels like a more reasonable starting point as well than introducing to many theme "container" objects.
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.
LGTM
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.
lgtm!
What does this PR do?
Adds an extend to the FormField container to style it differently based on the kind of child element (TextInput, TextArea, etc.).
Marking as a draft because I need to add the TS types and a jest test
Where should the reviewer start?
What testing has been done on this PR?
How should this be manually tested?
Do Jest tests follow these best practices?
screen
is used for querying.asFragment()
is used for snapshot testing.Any background context you want to provide?
What are the relevant issues?
Closes #7495
Screenshots (if appropriate)
Do the grommet docs need to be updated?
Yes
Should this PR be mentioned in the release notes?
Yes
Is this change backwards compatible or is it a breaking change?
backwards compatible