Skip to content

Commit

Permalink
fix(button): prevent click on disabled for older browser version
Browse files Browse the repository at this point in the history
  • Loading branch information
skhamvon authored and feoche committed May 21, 2024
1 parent c7c5be3 commit ea9ee09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ class OdsButtonController {
* Handle Click and KeyPress Event on the button
*/
handleClick(event: MouseEvent): void {
if (!this.component.disabled) {
this.submitForm(event);
}
this.submitForm(event);
}

handleKey(event: KeyboardEvent): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ export class OsdsButton implements OdsButtonAttribute {
}

@Listen('click')
handleClick(event: MouseEvent) {
handleClick(event: MouseEvent){
if(this.disabled){
event.preventDefault();
event.stopPropagation();

return;
}
this.controller.handleClick(event);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/examples/react-webpack/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const App = () => {
Submit
</OsdsButton>

<OsdsButton type={ ODS_BUTTON_TYPE.button } disabled="" onClick={() => alert("clicked")}
<OsdsButton type={ ODS_BUTTON_TYPE.button } disabled={true} onClick={() => alert("clicked")}
>
Test Disabled
</OsdsButton>
Expand Down

0 comments on commit ea9ee09

Please sign in to comment.