Skip to content
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

but(FormFiled): Floating label hide/show not responsive when set to outline appearance. #29939

Open
1 task
Cole-Jaeger opened this issue Oct 29, 2024 · 5 comments
Labels
area: material/form-field P4 A relatively minor issue that is not relevant to core functions

Comments

@Cole-Jaeger
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When you have a mat form field and the mat-label is conditional. If the view starts with the label and gets remove with @if in template it is perfectly fine. Will disappear and reappear. If the view starts with-out the mat label rendered, the label will get rendered but the component, 'MatFormFieldNotchedOutline" still has the class, 'mdc-notched-outline--no-label', so the display is set to none.

Looks as though if the mat-label is not there on view init it is not responsive.

The behavior works fine with fill appearance.

Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

Expected Behavior

When mat-label gets rendered in even after init, i.e. Using a structural directive or decorator such *ngIf or @if. The label should show no matter the appearance.

Actual Behavior

When you have the appearance set to outline and the view is initially rendered without the label it is not responsive and will not show up.

Environment

  • Angular: 18.2.10
  • CDK/Material: 18.2.10
  • Browser(s): Edge, Chrom
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@Cole-Jaeger Cole-Jaeger added the needs triage This issue needs to be triaged by the team label Oct 29, 2024
@Totati
Copy link
Contributor

Totati commented Oct 29, 2024

Duplicate of #26579

@Cole-Jaeger
Copy link
Author

I don't think this is a duplicate of that other bug. That one is only happening on fill appearance while this is happening on the outline appearance. This is a specific issue of what it seems like is in the "ngAfterViewInit" in the MatFormFieldNotchedOutline component. A component that does not even get added when appearance is set to fill.

@amysorto
Copy link
Contributor

Hi @Cole-Jaeger, can you provide a StackBlitz with the issue reproduced. This is the template for it: https://stackblitz.com/fork/components-issue-starter

@amysorto amysorto added needs: clarification The issue does not contain enough information for the team to determine if it is a real bug area: material/form-field and removed needs triage This issue needs to be triaged by the team labels Oct 30, 2024
@Cole-Jaeger
Copy link
Author

Absolutely @amysorto !
https://stackblitz.com/edit/components-issue-starter-gjragy?file=src%2Fmain.ts

This is a super simple example in my app the "showLabel" is based off of a media break point but this example just uses a simple toggle.

Please let me know if you need anything else

Thank you.

@amysorto
Copy link
Contributor

amysorto commented Nov 1, 2024

@Cole-Jaeger thanks for the link, I am able to reproduce the issue

@amysorto amysorto added P4 A relatively minor issue that is not relevant to core functions and removed needs: clarification The issue does not contain enough information for the team to determine if it is a real bug labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/form-field P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

3 participants