Button: Disabled button click event triggering
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
- Create a p-button component from the ButtonModule
- Set the click event
- Set the disabled state
- 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.
I have the same issue when updated from 17.18.0 to 17.18.1
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.
> 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;
- Launching the reproducer provided in this issue
- The PrimeNG version is 17.8.1 (note the functionality also works in the current version of PrimeNG, 17.8.2)
- The p-button clicking functionality with the onClick callback is disabled
- Changing the PrimeNG supported onClick callback api to the unsupported click api
- 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