Skip to content

Commit

Permalink
Merge pull request #16366 from pahan35/fix/lost-control-false
Browse files Browse the repository at this point in the history
Addon-controls: Fix `{control: false}` handling
  • Loading branch information
shilman authored Oct 16, 2021
2 parents 43bc8cc + 1fc38e6 commit 6717fce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 20 additions & 0 deletions lib/store/src/normalizeInputTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ describe('normalizeInputType', () => {
defaultValue: 'defaultValue',
});
});

it('preserves disabled control via shortcut', () => {
expect(
normalizeInputType(
{
type: 'string',
control: false,
description: 'description',
defaultValue: 'defaultValue',
},
'arg'
)
).toEqual({
name: 'arg',
type: { name: 'string' },
control: { disable: true },
description: 'description',
defaultValue: 'defaultValue',
});
});
});

describe('normalizeInputTypes', () => {
Expand Down
6 changes: 5 additions & 1 deletion lib/store/src/normalizeInputTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export const normalizeInputType = (inputType: InputType, key: string): StrictInp
...rest,
};
if (type) normalized.type = normalizeType(type);
if (control) normalized.control = normalizeControl(control);
if (control) {
normalized.control = normalizeControl(control);
} else if (control === false) {
normalized.control = { disable: true };
}
return normalized;
};

Expand Down

0 comments on commit 6717fce

Please sign in to comment.