-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Menu | itemClick requires double click in popup mode if items generated by function #13934
Comments
any suggestions? |
In fiddling with this trying to find a workaround, I noticed that the bug goes away if you set an invalid appendTo, but not if you leave off appendTo. In comparing the menu objects after toggling, I noticed the ones that don't work (those without invalid appendTo), have a documentClickListener defined that points to a function called removeEventListener. Whereas the menu with the invalid appendTo does not have this. Also after the MenuItem command is executed, I notice none of the menus have this documentClickListener set. Stackblitz example: https://stackblitz.com/edit/8numcb-2leua7 I'm not sure how to formulate a workaround based on this, or if it has anything to do with the issue. I tried removing the documentClickListener in the toggle event to see if that works without luck, but I'm not sure I'm doing so correctly. Perhaps this documentClickListener needing to be consumed is what the first/ineffective click on a menu item is accomplishing. After which point the second click is then able to work? |
Hi, Thanks a lot for reporting the issue, great catch! |
Hi, After investigating the matter, I've discovered an interesting correlation with the tabindex attribute within the |
@cetincakiroglu Do you know if this fix will be added to a version 16 release after being verified in 17? In the stackblitz example I tried setting tabindex to undefined, null, and a value in both the menuItem html attributes and the model attributes, and it didn't seem to provide a workaround. |
Try this
|
@cetincakiroglu That doesn't seem to work either: |
Please see the example: https://stackblitz.com/edit/8numcb-fyvbtn?file=src%2Fapp%2Fdemo%2Ftable-basic-demo.html |
@cetincakiroglu I'm hoping for a work around for version 16 so that we're able to be on an LTS release. |
@dnordahl1 I have implemented this workaround: Hope this helps someone :) |
@IvanNovikov-mobdev Excellent.. I'm very grateful for you sharing this! |
@cetincakiroglu This is still an issue in 17.9.0 |
Hi, Thanks for letting us know, we'll check before 17.13.0 release. |
Is it known if this is fixed in 17.18.4 before we upgrade to it? We're been stuck on 15 because we can't afford to introduce this issue. |
The workaround |
Hello, For some reason i am still facing the problem with 17.18.9 and 17.18.10 <div class="card flex justify-content-center">
<p-menu #menu
[tabindex]="undefined" styleClass="z-2" [model]="getMenuItemsForItem(item)" [popup]="true" appendTo="body">
<ng-template pTemplate="item" let-mitem>
@if (mitem.route) {
<a [routerLink]="mitem.route" class="p-menuitem-link">
<span [class]="mitem.icon"></span>{{mitem.route+''+item.id}}
<span class="ml-2">{{ mitem.label }}</span>
</a>
} @else {
<a class="p-menuitem-link">
<span [class]="mitem.icon"></span>
<span class="ml-2">{{ mitem.label }}</span>
</a>
}
</ng-template>
</p-menu>
<p-button [rounded]="true" [outlined]="true" (onClick)="menu.toggle($event)" icon="pi pi-ellipsis-v"/>
</div> with this in ts getMenuItemsForItem(item: Survey): MenuItem[] {
return [
{
label: 'Options',
items: [
{
label: 'Edit',
icon: 'pi pi-file-edit',
route: '/survey/add/'+item.id,
},
{
label: 'Manage answers',
icon: 'pi pi-chart-bar',
route: '/participation/survey/'+item.id,
},
{separator: true},
{
label: 'Delete',
icon: 'pi pi-trash',
style: {'color': 'red'},
command: () => {
this.deleteCl(item.id)
}
}
]
}
] |
The issue is present in v.17.18. I have set |
thank you so much, works with me |
Describe the bug
Component: Menu inside a table row.
User should click twice on menu action to reach an action.
Environment
Reproducer
https://stackblitz.com/edit/8numcb-pnb4qf?file=src%2Fapp%2Fdemo%2Ftable-basic-demo.html
Angular version
16.2.0
PrimeNG version
16.5.1
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
v18.12.1
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
When user click first time on menu action. Action should be execute.
The text was updated successfully, but these errors were encountered: