primeng icon indicating copy to clipboard operation
primeng copied to clipboard

primeNG p-autocomplete autofocus

Open policz opened this issue 7 years ago • 9 comments

Hello i'm using p-autocomplete element tag ,which is not inside of p-dialog box,

i'm trying to implement autofocus to a particular area or element upon opening a model window i have tried with different ways of implementation but nothing gets solve my issue.

From my investigation, when the onAutoShow() function triggers just (this.resourceSignum) gets undefined

Below is my code of html and component. .html file

<p-autoComplete #name (onShow)= "onAfterShow()">

component.ts file

import { AutoComplete } from 'primeng/autocomplete';

@ViewChild('name') private name: AutoComplete;

onAfterShow() { this.name.focusInput(); }

policz avatar Apr 22 '19 17:04 policz

Autocomplete doesn't have an (onShow) event, only dialog does.

JacobSiegle avatar Apr 23 '19 13:04 JacobSiegle

Hey JacobSiegle Thanks for your comment

Actually i tried with (onFocus) to trigger an event but its not happening, so i tried with (onShow) but its useless any suggestion

policz avatar Apr 23 '19 13:04 policz

You need to wait for the viewchild element in the primeng component to load. Here's a really quick example - https://stackblitz.com/edit/github-1n5qef?file=src/app/app.component.ts. You can probably find more elegant solutions by searching for this common problem.

JacobSiegle avatar Apr 23 '19 13:04 JacobSiegle

Thank you and i will try to implement in your way..!

policz avatar Apr 23 '19 13:04 policz

hey tired but i'm getting error please find the belo inputEl w screenshot

policz avatar Apr 23 '19 14:04 policz

There's something in your code not being shown in the issue to get that error. I don't believe this is an issue but a help request. You can try to post to the primeng forums for help requests https://forum.primefaces.org/.

JacobSiegle avatar Apr 23 '19 14:04 JacobSiegle

It seems like your code is using https://ng-bootstrap.github.io/#/components/modal/examples. You need to sync running your code when the dialog appropriately shows most likely. I don't use ng-bootstrap so I cannot assist you and this is not an issue with PrimeNG so it shouldn't be posted here.

JacobSiegle avatar Apr 23 '19 15:04 JacobSiegle

yes i'm using ng-bootstrap for the model windows

policz avatar Apr 23 '19 15:04 policz

Please use forum for discussions.

cagataycivici avatar Apr 24 '19 07:04 cagataycivici