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

TreeTable: Row selected on click at node toggle icon #6932

Closed
KriXPello opened this issue Dec 7, 2024 · 1 comment · Fixed by #6933
Closed

TreeTable: Row selected on click at node toggle icon #6932

KriXPello opened this issue Dec 7, 2024 · 1 comment · Fixed by #6933
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@KriXPello
Copy link
Contributor

Describe the bug

TreeTable toggles selection when clicked exactly on expand icon (when clicked directly on button works fine). Here is example:

treetable_bug

Reproducer

https://stackblitz.com/edit/primevue-4-vite-issue-template-fz8jucim

PrimeVue version

4.2.4

Vue version

4.x

Language

ALL

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

  1. Open my stackblitz link
  2. Click on any expandable TreeTable row to select it like so:
    image
  3. Click on expand icon in different places until it remove selection. In my case i was able to toggle selection by click there:
    image

Expected behavior

When you click on a button or icon in that button, the row should expand without selection.

I was able to find that problem is in packages\primevue\src\treetable\TreeTableRow.vue in onClick method:

onClick(event) {
    // problem here
    if (isClickable(event.target) || getAttribute(event.target, 'data-pc-section') === 'nodetogglebutton' || getAttribute(event.target, 'data-pc-section') === 'rowtoggleicon' || event.target.tagName === 'path') {
        return;
    }

    this.setTabIndexForSelectionMode(event, this.nodeTouched);

    this.$emit('node-click', {
        originalEvent: event,
        nodeTouched: this.nodeTouched,
        node: this.node
    });
    this.nodeTouched = false;
}

Need to add || getAttribute(event.target, 'data-pc-section') === 'nodetoggleicon' check, because icon has attribute data-pc-section="nodetoggleicon", not the rowtoggleicon

@KriXPello KriXPello added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 7, 2024
@KriXPello
Copy link
Contributor Author

KriXPello commented Dec 9, 2024

for thoose who don't want to wait, there is temporary solution:
in entry file of your Vue application (with const app = createApp(App);) write:

const originalGetAttribute = Element.prototype.getAttribute;
Element.prototype.getAttribute = function (name) {
  const realValue = originalGetAttribute.call(this, name);
  if (name === 'data-pc-section' && realValue == 'nodetoggleicon') {
    return 'rowtoggleicon';
  }
  return realValue;
};

@tugcekucukoglu tugcekucukoglu added this to the 4.2.5 milestone Dec 10, 2024
@github-project-automation github-project-automation bot moved this to Review in PrimeVue Dec 10, 2024
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 10, 2024
@tugcekucukoglu tugcekucukoglu self-assigned this Dec 10, 2024
@github-project-automation github-project-automation bot moved this from Review to Done in PrimeVue Dec 10, 2024
tugcekucukoglu added a commit that referenced this issue Dec 10, 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
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants