question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: this._getHostElement(...).focus is not a function

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Using this guide I would like to be able render app without errors.

What is the current behavior?

Currently I’m recieving error:

ERROR { Error: Uncaught (in promise): TypeError: this._getHostElement(...).focus is not a function
TypeError: this._getHostElement(...).focus is not a function
    at MdOption.focus (home_path/node_modules/@angular/material/bundles/material.umd.js:1638:32)
    at FocusKeyManager.setActiveItem (home_path/node_modules/@angular/material/bundles/material.umd.js:6787:29)
    at MdSelect._selectValue (home_path/node_modules/@angular/material/bundles/material.umd.js:7454:30)
    at MdSelect._setSelectionByValue (home_path/node_modules/@angular/material/bundles/material.umd.js:7431:18)
    at MdSelect.writeValue (home_path/node_modules/@angular/material/bundles/material.umd.js:7237:18)
    at home_path/node_modules/@angular/forms/bundles/forms.umd.js:1810:29
    at home_path/node_modules/@angular/forms/bundles/forms.umd.js:2996:65
    at Array.forEach (native)
    at FormControl.setValue (home_path/node_modules/@angular/forms/bundles/forms.umd.js:2996:28)
    at home_path/node_modules/@angular/forms/bundles/forms.umd.js:4398:60
    at resolvePromise (home_path/node_modules/zone.js/dist/zone-node.js:783:31)
    at home_path/node_modules/zone.js/dist/zone-node.js:834:17
    at ZoneDelegate.invokeTask (home_path/node_modules/zone.js/dist/zone-node.js:424:31)
    at Object.onInvokeTask (home_path/node_modules/@angular/core/bundles/core.umd.js:3913:33)
    at ZoneDelegate.invokeTask (home_path/node_modules/zone.js/dist/zone-node.js:423:36)
    at Zone.runTask (home_path/node_modules/zone.js/dist/zone-node.js:191:47)
    at drainMicroTaskQueue (home_path/node_modules/zone.js/dist/zone-node.js:595:35)
    at ZoneTask.invokeTask (home_path/node_modules/zone.js/dist/zone-node.js:502:21)
    at ZoneTask.invoke (home_path/node_modules/zone.js/dist/zone-node.js:487:48)
    at data.args.(anonymous function) (home_path/node_modules/zone.js/dist/zone-node.js:1063:25)

However, I’m still able to produce out html.

What are the steps to reproduce?

I have these modules Looking at the error message it seems that select is causing this, so here is my select: Example code:

...
  buttons = ["left", "middle", "right"]
  button = this.buttons[0]
...
  <md-select (change)="change()" [(ngModel)]="button">
    <md-option *ngFor="let mb of buttons" [value]="mb">{{ mb | uppercase }}</md-option>
  </md-select>
...

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular - 4.3.3 Material - 2.0.0-beta.8 OS - Ubuntu 16.10 TypeScript - 2.4.2

Is there anything else we should know?

For some reason Current document does not have a doctype. This may cause some Angular Material components not to behave as expected. is outputed, however, I do have doctype.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
halbencommented, Aug 18, 2017

Any update on why

For some reason Current document does not have a doctype. This may cause some Angular Material components not to behave as expected. is outputed, however, I do have doctype.

is being outputted?

1reaction
crisbetocommented, Aug 13, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: this._getHostElement(...).focus is not a function ...
This may cause some Angular Material components not to behave as expected. is outputed, however, I do have doctype .
Read more >
Javascript: Focus is not a function - html - Stack Overflow
Your Forename variable is not holding a reference to a DOM element. It is referencing the .value of that element. The same is...
Read more >
Focus() and nativeelement.focus() not working in angular 10
I am trying to put the focus on a dropdown item, on page load. Am not sure but do I need to add...
Read more >
Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError - Some selector is not a function - jQuery is not a function - owlCarousel...
Read more >
Uncaught TypeError: el.focus is not a function - Bountysource
Hi I try to use the angular-strap library but I received this error. Uncaught TypeError: el.focus is not a function. This is my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found