Skip to content

Commit

Permalink
fix(core): prevent toolbar buttons from being clicked if shouldBeDisa…
Browse files Browse the repository at this point in the history
…bled returns true (carbon-design-system#1429)

* fix(core): prevent toolbar buttons from being clicked if shouldBeDisabled returns true

fix carbon-design-system#1424

* Simplify condition into one

Signed-off-by: Akshat Patel <akshat@live.ca>

Signed-off-by: Akshat Patel <akshat@live.ca>
  • Loading branch information
Akshat55 committed Aug 15, 2022
1 parent fa982e0 commit 83aeb93
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/components/axes/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ export class Toolbar extends Component {

// Calls passed function && dispatches event
triggerFunctionAndEvent(control, event, element?) {
// Check if trigger is disabled
if (
typeof control.shouldBeDisabled === 'function' &&
control.shouldBeDisabled()
) {
return;
}

// Call custom function only if it exists
if (typeof control.clickFunction === 'function') {
control.clickFunction(event);
Expand Down

0 comments on commit 83aeb93

Please sign in to comment.