Skip to content

Conversation

jcfilben
Copy link
Collaborator

@jcfilben jcfilben commented Jan 30, 2025

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.
  • The correct query is used. (Refer to this list of queries)
  • 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

@jcfilben jcfilben marked this pull request as draft January 30, 2025 23:44
Children.forEach(children, (child) => {
if (child && child.type) {
childName = child.type.displayName;
if (childName?.length > 1)
Copy link
Collaborator

@taysea taysea Jan 30, 2025

Choose a reason for hiding this comment

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

Suggested change
if (childName?.length > 1)
// camelCase component name to match theme object key
if (childName?.length > 1)

Copy link
Collaborator

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?

Copy link
Collaborator

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?

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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)

Copy link
Collaborator

@taysea taysea left a 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.

@jcfilben jcfilben marked this pull request as ready for review January 31, 2025 16:40
Copy link
Collaborator

@britt6612 britt6612 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@taysea taysea left a comment

Choose a reason for hiding this comment

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

lgtm!

@jcfilben jcfilben merged commit b550cf0 into grommet:master Jan 31, 2025
13 of 14 checks passed
@jcfilben jcfilben deleted the formfield-type-extend branch January 31, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FormField -- theme to support input specific container styling
3 participants