Skip to content

Conversation

@tamara-corbalt
Copy link
Collaborator

@tamara-corbalt tamara-corbalt commented Oct 27, 2025

Summary

  • Refactors the getTextFieldChild utility used by Autocomplete to remove usage on React’s legacy Children API.
  • Normalizes children to an array (when not already an array) and iterates directly to return the TextField element.
  • Adds unit tests to verify parity to the original version.
    Jira ticket

How to test

  • Run unit tests npm run test:unit -t Autocomplete
  • For parity verification: replace the updated function in utils.tsx with the original version below and re-run the tests.
export function getTextFieldChild(children: ReactNode): ReactElement<any> | undefined {
  let textField: ReactElement<any> | undefined;
  Children.forEach(children, (child) => {
    if (isTextField(child)) {
      textField = child;
    }
  });
  return textField;
}

Checklist

  • Prefixed the PR title with the Jira ticket number as [CMSDS-####] Title or [NO-TICKET] if this is unticketed work.
  • Selected appropriate Type (only one) label for this PR, if it is a breaking change, label should only be Type: Breaking
  • Selected appropriate Impacts, multiple can be selected.
  • Selected appropriate release milestone

@tamara-corbalt tamara-corbalt added this to the 13.2.0 milestone Oct 27, 2025
@tamara-corbalt tamara-corbalt added Impacts: Core Impacts the core DS primarily, changes may occur in other themes as well. Type: Changed Indicates a change to an existing element of the DS. labels Oct 27, 2025
@tamara-corbalt tamara-corbalt self-assigned this Oct 27, 2025
@tamara-corbalt tamara-corbalt marked this pull request as ready for review October 27, 2025 19:16
Copy link
Collaborator

@jack-ryan-nava-pbc jack-ryan-nava-pbc left a comment

Choose a reason for hiding this comment

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

This works great. Tests pass. Minor non-blocking comment. Thanks for doing this!

renderAutocomplete({
children: <div>Not a text field</div>,
})
).toThrow();
Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests pass (wahoo!) however I find these throws to be a bit noisy. Is there a way to mute the console output?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep good call, just added this commit, which should take the noise factor down on these. Thanks for catching that!

@tamara-corbalt tamara-corbalt merged commit 2d0df36 into milestone/13.2 Oct 28, 2025
1 check passed
@tamara-corbalt tamara-corbalt deleted the tdement/CMSDS-3663/remove-children-api-usage-autocomplete branch October 28, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Impacts: Core Impacts the core DS primarily, changes may occur in other themes as well. Type: Changed Indicates a change to an existing element of the DS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants