Skip to content

Commit

Permalink
Merge pull request #19877 from gitstart/addon-controls/fix-controls-c…
Browse files Browse the repository at this point in the history
…ount

Addon-controls: Exclude `{ table: { disable: true } }` controls while counting controls for panel title
  • Loading branch information
valentinpalkovic authored Nov 22, 2022
2 parents 52c879a + dfe79a6 commit ddca95b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion code/addons/controls/src/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ addons.register(ADDON_ID, (api: API) => {
addons.addPanel(ADDON_ID, {
title() {
const rows = useArgTypes();
const controlsCount = Object.values(rows).filter((argType) => argType?.control).length;
const controlsCount = Object.values(rows).filter(
(argType) => argType?.control && !argType?.table?.disable
).length;
const suffix = controlsCount === 0 ? '' : ` (${controlsCount})`;
return `Controls${suffix}`;
},
Expand Down
4 changes: 3 additions & 1 deletion code/addons/controls/template/stories/disable.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ export const DisableTable = {

export const DisableControl = {
args: { a: 'a', b: 'b' },
b: { control: { disable: true } },
argTypes: {
b: { control: { disable: true } },
},
};

0 comments on commit ddca95b

Please sign in to comment.