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

DataTable - button click in a cell propagates to row-click #6472

Closed
juliepetrova opened this issue Sep 25, 2024 · 2 comments · Fixed by #6544
Closed

DataTable - button click in a cell propagates to row-click #6472

juliepetrova opened this issue Sep 25, 2024 · 2 comments · Fixed by #6544
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@juliepetrova
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Clicking on a button inside a row in PrimeVue's DataTable still triggers the row's onRowClick event, which causes unwanted navigation. The patch prevents this by checking if the click target has the class 'p-button' and halting further execution if it does (it is a workaround and not an actual solution of course). In this example the button is used to open a ConfirmPopup element which, when stopPropagation is applied, is misplaced. (#5929)

Here is the diff that solved my problem:

diff --git a/node_modules/primevue/datatable/index.mjs b/node_modules/primevue/datatable/index.mjs
index 47a9440..6bfe420 100644
--- a/node_modules/primevue/datatable/index.mjs
+++ b/node_modules/primevue/datatable/index.mjs
@@ -1467,6 +1467,9 @@ var script$8 = {
       });
     },
     onRowClick: function onRowClick(event) {
+      if(event.target.className.includes('p-button')) {
+        return;
+      };
       this.$emit('row-click', {
         originalEvent: event,
         data: this.rowData,

This issue body was partially generated by patch-package.

@sid-6581
Copy link
Contributor

The same thing happens for regular anchors, and probably anything else clickable. It seems #6333 is likely responsible for the regression.

@colinatwork
Copy link

We are also seeing this

@tugcekucukoglu tugcekucukoglu added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Oct 3, 2024
@tugcekucukoglu tugcekucukoglu added this to the 4.1.1 milestone Oct 16, 2024
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

Successfully merging a pull request may close this issue.

4 participants