Right click on PrimeFaces tree node does not trigger select event
Clash Royale CLAN TAG#URR8PPP
Right click on PrimeFaces tree node does not trigger select event
I am using a PrimeFaces 6.2 p:tree
component with a context menu which differ for each node. When I click left and then right the menu is rendered properly, but when I click right directly the menu is not updated. Any ideas how to solve it?
p:tree
I know that there are some posts about ajax after right click (event contextMenu
), but it does not help, because the context menu disappears.
contextMenu
Sample p:tree
can look like:
p:tree
<p:tree id="docs" value="#treeContextMenuView.root" var="doc"
selectionMode="single"
selection="#treeContextMenuView.selectedNode" dynamic="true">
<p:ajax event="select" update="form:contextMenu" />
<p:treeNode expandedIcon="ui-icon-folder-open"
collapsedIcon="ui-icon-folder-collapsed">
<h:outputText value="#doc.name" />
</p:treeNode>
<p:treeNode type="document" icon="ui-icon-document">
<h:outputText value="#doc.name" />
</p:treeNode>
<p:treeNode type="picture" icon="ui-icon-image">
<h:outputText value="#doc.name" />
</p:treeNode>
<p:treeNode type="mp3" icon="ui-icon-video">
<h:outputText value="#doc.name" />
</p:treeNode>
</p:tree>
and sample p:contextMenu
like:
p:contextMenu
<p:contextMenu for="docs" id="contextMenu">
<p:menuitem value="View" update="messages"
actionListener="#treeContextMenuView.displaySelectedSingle"
icon="ui-icon-search" />
<p:menuitem value="Item for Documents"
rendered="#treeContextMenuView.selectedNode.data.name eq 'Documents'"
icon="ui-icon-print" />
<p:menuitem value="Delete" update="docs"
actionListener="#treeContextMenuView.deleteNode"
icon="ui-icon-close" />
</p:contextMenu>
Full reproducible MVCE: https://github.com/szydra/primefaces-test
edit: Recently, I have found the same issue reported for p:dataTable
:
issue on github.
p:dataTable
@Melloware Please see my example on github. I have copied the PrimeFaces showcase example and add a special item for 'Documents'. The context menu is not rendered properly, when you use only right click.
– szydra
Aug 11 at 18:16
Excellent work on a reproducible sample. I would create a GitHub issue and reference that DataTable Issue you found on GitHub. It definitely seems like a similar issue with a similar potential fix.
– Melloware
Aug 12 at 14:58
Please everone, stackoverlow 'requires' Minimal, Complete, and Verifiable example to be posted inline here. Not an mcve like the ones PrimeFaces 'requires'... external sites have no guarantee to stay online in the future. See How to Ask Please improve the question here
– Kukeltje
Aug 12 at 16:01
@Kukeltje Updated.
– szydra
Aug 13 at 7:20
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Please create an MVCE reproducing the problem using this sample project: github.com/primefaces/primefaces-test
– Melloware
Aug 10 at 16:45