Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #154 from martinpovolny/toolbar_fix_onwhen
Browse files Browse the repository at this point in the history
Fix enabled calculation: use "onwhen" when available if not use "enabled".
  • Loading branch information
karelhala authored Oct 2, 2019
2 parents 43c1be9 + 5480560 commit 76cce4b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/toolbar/ToolbarButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ButtonIcon.propTypes = {

export const ToolbarButton = (props) => {
const count = useContext(CountContext);
const disabled = !props.enabled || !isEnabled(props.onwhen, count);
const disabled = !(props.onwhen ? isEnabled(props.onwhen, count) : props.enabled);

return (
<button
Expand Down
2 changes: 1 addition & 1 deletion src/toolbar/ToolbarList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ToolbarList = (props) => {
// Toolbar is disabled if no item is enabled.
let isToolbarEnabled = false;
const enabledItems = visibleItems.map((i) => {
const enabled = i.enabled && isEnabled(i.onwhen, count);
const enabled = i.onwhen ? isEnabled(i.onwhen, count) : i.enabled;
isToolbarEnabled = isToolbarEnabled || enabled;

return {
Expand Down

0 comments on commit 76cce4b

Please sign in to comment.