Skip to content

bug(cdk/text-field): material text area input placeholder shows 'undefined' when using cdkTextareaAutosize #24154

Closed
@quoctintran

Description

@quoctintran

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 using cdkTextareaAutosize in the textarea as matInput, the placeholder was explicitly set as undefined and a value was patched, the placeholder shows 'undefined' after deleting the value (control still focused). All this happens as long as the control is focused. You can try it by typing another value and delete it again completely. The undefined placeholder disappears if the control loses focus (click somewhere else on the page). If you type a new value and delete it again, the placeholder is correct.

After removing all the cdk inputs (cdkTextareaAutosize, cdkAutosizeMinRows, cdkAutosizeMaxRows), the placeholder is correct (empty).

image

Reproduction

https://stackblitz.com/edit/angular-t7rq43?file=src/app/input-overview-example.html

Steps to reproduce:

  1. Open stackblitz example
  2. Delete the text in the textarea field
  3. Keep the focus in the control
  4. Optional: Type another value and delete it again
  5. Optional: Keep the focus in the control

Expected Behavior

No placeholder is shown even the placeholder is set as undefined

Actual Behavior

Placeholder shows text 'undefined'

Environment

  • Angular: 12.2.15, 12.2.9, 12.1.0
  • CDK/Material: 12.2.13, 12.2.9, 12.1.0
  • Browser(s): Edge - Version 96.0.1054.62 (Official build) (64-bit)
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10 - Version 2004 (OS Build 19041.1288)

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/text-field

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions