Skip to content

feat(mat-form-field): Support nested content projection for _formFieldControl #31196

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

Open
bamblack opened this issue May 22, 2025 · 1 comment
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team

Comments

@bamblack
Copy link

Feature Description

Allow the MatFormFieldControl within the mat-form-field component to be accessed through nested content projection

Use Case

I have a use case where I'm attempting to write a component that wraps mat-form-field for the purpose of "easier" error configuration, allowing devs to pass a { key: string, message: string }[] to my component. I have a simple StackBlitz showing what currently "works" and how I'd like it to work: https://stackblitz.com/edit/components-issue-starter-yqzq6dje?file=src%2Fcustom-form-field-wrap.ts. Basically, I think if you were to add { descendants: true } to the definition of _formFieldControl in mat-form-field it would allow my use case. Although, I'm not sure what other, if any, repercussions of that change would be.

@bamblack bamblack added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels May 22, 2025
@bamblack
Copy link
Author

bamblack commented May 22, 2025

Well, after doing research it looks like my suggested action wouldn't fix it, because the default of descendants is already true and ContentChild can't pierce multiple levels of content projection through components like I thought it could. Back to the drawing board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

1 participant