Skip to content

Commit

Permalink
fix(select): use disabled attribute on readonly select
Browse files Browse the repository at this point in the history
  • Loading branch information
apust committed Dec 24, 2020
1 parent f3e042f commit a813713
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/packages/core/src/base-input/BaseInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export function BaseInput<T extends HTMLAttributesComposite>(props: BaseInputPro
{
cloneElement<T>(children, {
className: '_e_input__control',
disabled: appearance === 'disabled',
disabled: appearance === 'disabled' || (children.type === 'select' && appearance === 'readonly'),
placeholder: ' ',
readOnly: appearance === 'readonly',
readOnly: appearance === 'readonly' && children.type !== 'select',
...rest,
})
}
Expand Down
30 changes: 30 additions & 0 deletions src/packages/core/src/select/Select.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,33 @@ import { Select } from '.';
]}
/>
</Preview>

<Preview>
<Select
appearance="readonly"
label="Option"
defaultValue="2"
width="4"
options={[
{ value: '', title: '' },
{ value: '1', title: 'One' },
{ value: '2', title: 'Two' },
{ value: '3', title: 'Three' },
]}
/>
</Preview>

<Preview>
<Select
appearance="disabled"
label="Option"
defaultValue="2"
width="4"
options={[
{ value: '', title: '' },
{ value: '1', title: 'One' },
{ value: '2', title: 'Two' },
{ value: '3', title: 'Three' },
]}
/>
</Preview>

0 comments on commit a813713

Please sign in to comment.