primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
9.84k stars 4.5k forks source link

Button: Disabled button click event triggering #15857

Open adri95cadiz opened 2 weeks ago

adri95cadiz commented 2 weeks ago

Describe the bug

When clicking a p-button component in disabled state the button is triggering anyways, this didn't happen in version 17.18.0. The onClick event doesn't trigger, or the click event on a button with the pButton directive. I don't know if this is expected behaviour, anyways, for now we're reverting to version 17.18.0 until this is cleared.

Environment

We have an Angular web application with Primeng 17.18.1 and Angular version 18.0.3.

Reproducer

https://stackblitz.com/edit/github-qxeuwn?file=src%2Fapp%2Fapp.component.html

Angular version

18.0.3

PrimeNG version

17.18.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.14.0

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a p-button component from the ButtonModule
  2. Set the click event
  3. Set the disabled state
  4. Press the button and the click event triggers even though the button is disabled

Expected behavior

The button shouldn't execute the click event when it is disabled.

Joebeurg commented 2 weeks ago

I have the same issue when updated from 17.18.0 to 17.18.1

adri95cadiz commented 1 week ago

Tested in version 17.18.2 and keeps happening.

Please I would like to have some news on the matter, whether this is planned to be fixed, or whether this is intended behaviour and how it should be approached in that case.

For now our team is staying on version 17.18.0 until this is clarified.

rosenthalj commented 6 days ago

> Tested in version 17.18.2 and keeps happening.

Please I would like to have some news on the matter, whether this is planned to be fixed, or whether this is intended behaviour and how it should be approached in that case.

For now our team is staying on version 17.18.0 until this is clarified.

I believe that this issue #15857 is invalid and should be closed. The functionality is working properly. The official PrimeNG click API is onClick and the reproducer provided in issue #15857 is actually working properly. If a developer uses the unsupported click callback, the PrimeNG disabled state has no effect. HTML elements have a click callback which is probably causing the problem/confusion.

The video listed below shows the following;

  1. Launching the reproducer provided in this issue
  2. The PrimeNG version is 17.8.1 (note the functionality also works in the current version of PrimeNG, 17.8.2)
  3. The p-button clicking functionality with the onClick callback is disabled
  4. Changing the PrimeNG supported onClick callback api to the unsupported click api
  5. The p-button clicking functionality with the unsupported click callback is not disabled

https://github.com/primefaces/primeng/assets/45439491/78ef2ee2-d805-4567-9d00-7873a8bb8176