Reputation: 1868
I'm working with this multiselect and I'm trying to add focus on dropdown while having options open (please see attached picture to see what I'm trying to accomplish).
So far when I click on dropdown I only see the options but the focus from dropdown goes away. How can I keep focus on dropdown as well as having options open?
I'm trying to accomplish this:
Here's my code:
<p-multiSelect [options]="registrationStatus" [defaultLabel]="someText" [showHeader]="false"></p-multiSelect>
Upvotes: 1
Views: 5438
Reputation: 24424
overlayVisible
property of p-multiSelect
component will give a true/false value when the option panel is visable or hidden
template
<p-multiSelect [options]="registrationStatus"
[defaultLabel]="someText" [showHeader]="false"
#p [ngClass]="{'focus':p.overlayVisible}">
</p-multiSelect>
style.css
.focus .ui-dropdown, .focus .ui-multiselect {
-moz-box-shadow: 0px 0px 5px #1f89ce;
-webkit-box-shadow: 0px 0px 5px #1f89ce;
box-shadow: 0px 0px 5px #1f89ce;
}
this component has some event like onChange , onFocus , onBlur , onPanelShow , onPanelHide
will trige base on set of action so you can trigger some event like blur , or onPanelHide after this componnt lost focus (press tab)
Upvotes: 1
Reputation: 3823
ngAfterViewInit() {
this.elem = (document.querySelector('.ui-multiselect') as any);
this.elem.setAttribute('tabindex', -1);
}
demo https://stackblitz.com/edit/primeng-input-multiselect-nvwonk
you can add keyboard event etc.
Upvotes: 1