-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix(gcds-button): Prevent gcdsClick event if button is disabled #724
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a test for the fix?
…com/cds-snc/gcds-components into fix/disabled-button-gcdsClick-event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
While testing, I'm able to confirm that it does not fire Tested by adding this script on the index.html page in const button = document.getElementById('myButton');
button.addEventListener('click', () => {
console.log("Button was clicked!");
}); similar to how I verify that gcdsClick doesn't get emitted const container = document.querySelector('body'); // or any specific container
container.addEventListener('gcdsClick', (e) => {
console.log(`Event gcdsClick was emitted by`, e.target, 'with details:', e.detail);
}); here is my html: <gcds-heading tag="h2">Buttons</gcds-heading>
<gcds-button button-role="primary">Primary</gcds-button>
<gcds-button button-role="secondary">Secondary</gcds-button>
<gcds-button button-role="danger">Danger</gcds-button>
<gcds-button id="myButton" disabled>Click me!</gcds-button> 🤔 any ideas why? |
@daine With the HTML that is rendered in the |
Summary | Résumé
As mentioned in #720, the
gcdsClick
event will still fire even after the button has been disabled. Previous work has been made that will prevent HTML form submissions if the button is disabled but preventing thegcdsClick
event from emitting when disabled will allow easier use in applications.