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

p-dropdown input filter does not get focus anymore #6388

Closed
ASK83 opened this issue Aug 23, 2018 · 2 comments
Closed

p-dropdown input filter does not get focus anymore #6388

ASK83 opened this issue Aug 23, 2018 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ASK83
Copy link

ASK83 commented Aug 23, 2018

If you have a PrimeNG PRO Support subscription please post your issue at;

https://pro.primefaces.org

where our team will respond within 4 business hours.

If you do not have a PrimeNG PRO Support subscription, fill-in the report below. Please note that
your issue will be added to the waiting list of community issues and will be reviewed on a first-come first-serve basis, as a result, the support team is unable to guarantee a specific schedule on when it will be reviewed. Thank you for your understanding.

Current Waiting Time: ~8 weeks.

I'm submitting a ... (check one with "x")

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
The case can be seen on the site under dropdown with filters

https://www.primefaces.org/primeng/#/dropdown

Current behavior
When dropdown is clicked the input filter does not get a focus as it used to. This was working before in some other versions but not anymore.

Expected behavior
When filter is flagged the input filter should get focused after opening the dropdown, this was a behavior that was present in previous versions.

What is the motivation / use case for changing the behavior?
This is the expected behavior and used to be working. Looking at the code it seems the filterViewChild is undefined and that is the reasons the filter doesn't get focused anymore.

Please tell us about your environment:

  • Angular version: 5.X
    6.1.3

  • PrimeNG version: 5.X
    6.1.2

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    All

@Elanor-L
Copy link

Same trouble here. I found a workaround.
Instead of

this.show();
if (this.filterViewChild != undefined) {
setTimeout(() => {
this.filterViewChild.nativeElement.focus();
}, 200);
}

write

this.show();
//if (this.filterViewChild != undefined) {
    setTimeout(() => {
        if (this.filterViewChild != undefined)
            this.filterViewChild.nativeElement.focus();
    }, 200);
//  }

It's not the best solution but unfortunately i can't wait for the next release.

@mariusreusch
Copy link

Same problem here. We have a wrapper component for the primeng's dropdown and as a workaround we implemented (based on @Elanor-L answer) this:

onFocus() {
   setTimeout(() => {
      if(this.dropdownElement.filterViewChild !== undefined) {
         this.dropdownElement.filterViewChild.nativeElement.focus();
      }
   });
}

this.dropdownElement is a ViewChild referencing to primeng's dropdown and onFocus is bind to its onFocus event.

Same works with renderer2:

onFocus() {
   setTimeout(() => {
      if(this.dropdownElement.filterViewChild !== undefined) {
         this.renderer.selectRootElement(this.dropdownElement.filterViewChild.nativeElement).focus();
      }
   });
}

@cagataycivici cagataycivici self-assigned this Sep 18, 2018
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Sep 18, 2018
@cagataycivici cagataycivici added this to the 6.1.4 milestone Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

4 participants