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

bug(MatAutocomplete): cannot read property 'nativeElement' of undefined #22511

Closed
ggegelya opened this issue Apr 19, 2021 · 2 comments · Fixed by #22513
Closed

bug(MatAutocomplete): cannot read property 'nativeElement' of undefined #22511

ggegelya opened this issue Apr 19, 2021 · 2 comments · Fixed by #22513
Assignees
Labels
area: material/autocomplete P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@ggegelya
Copy link

ggegelya commented Apr 19, 2021

Reproduction

Here's StackBiz where you can reproduce error.
https://angular-ivy-uinb66.stackblitz.io
https://stackblitz.com/edit/angular-ivy-uinb66

Steps to reproduce:

  1. Select something in Brand
  2. Focus on Installment
  3. Press arrow down button twice to highlight one option
  4. Click on this option by mouse
  5. Press arrow down button again

Here's stacktrace of the error:

TypeError: Cannot read property 'nativeElement' of undefined at MatAutocompleteTrigger._scrollToOption (autocomplete.js:909) at MatAutocompleteTrigger._handleKeydown (autocomplete.js:605) at MatAutocompleteTrigger_keydown_HostBindingHandler (autocomplete.js:985) at executeListenerWithErrorHandling (core.js:15220) at wrapListenerIn_markDirtyAndPreventDefault (core.js:15255) at HTMLInputElement.<anonymous> (platform-browser.js:582) at ZoneDelegate.invokeTask (zone-evergreen.js:399) at Object.onInvokeTask (core.js:28522) at ZoneDelegate.invokeTask (zone-evergreen.js:398) at Zone.runTask (zone-evergreen.js:167)

Expected Behavior

No exception throwed.

Actual Behavior

TypeError: cannot read property 'nativeElement' of undefined

Environment

  • Angular: 11.2.3
  • CDK/Material: 11.2.2
  • Browser(s): Google Chrome 89.0.4389.114
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10
@ggegelya ggegelya added the needs triage This issue needs to be triaged by the team label Apr 19, 2021
@ggegelya ggegelya changed the title bug(COMPONENT): TITLE bug(MatAutocomplete): cannot read property 'nativeElement' Apr 19, 2021
@ggegelya ggegelya changed the title bug(MatAutocomplete): cannot read property 'nativeElement' bug(MatAutocomplete): cannot read property 'nativeElement' of undefined Apr 19, 2021
@crisbeto crisbeto self-assigned this Apr 19, 2021
@crisbeto crisbeto added area: material/autocomplete has pr P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Apr 19, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 19, 2021
Fixes an error that is thrown if a `keydown` event is dispatched before the autocomplete panel has been initialized.

Fixes angular#22511.
@ggegelya
Copy link
Author

@crisbeto thank you for taking this issue in work, is there any workaround for it?
i was thinking about MatAutocompleteTrigger and keydown handler where I can call trigger.openPanel(), but not sure if it will work it

wagnermaciel pushed a commit that referenced this issue Apr 21, 2021
…22513)

Fixes an error that is thrown if a `keydown` event is dispatched before the autocomplete panel has been initialized.

Fixes #22511.
wagnermaciel pushed a commit that referenced this issue Apr 21, 2021
…22513)

Fixes an error that is thrown if a `keydown` event is dispatched before the autocomplete panel has been initialized.

Fixes #22511.

(cherry picked from commit 0fbd3e7)
wagnermaciel pushed a commit that referenced this issue Apr 21, 2021
…22513)

Fixes an error that is thrown if a `keydown` event is dispatched before the autocomplete panel has been initialized.

Fixes #22511.

(cherry picked from commit 0fbd3e7)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/autocomplete P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants