Skip to content

Commit

Permalink
feat: Disabled state for dropdown list #28
Browse files Browse the repository at this point in the history
  • Loading branch information
lo5 committed Oct 18, 2022
1 parent ae5b1f0 commit e973aa2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
18 changes: 18 additions & 0 deletions help/docs/guide/dropdown-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,21 @@ while True:


![Screenshot](assets/screenshots/multi_dropdown_live.png)


## Disable

Set `disabled=True` to disable.


```py
view(box(
'Choose some colors',
mode='multi menu',
options=['green', 'yellow', 'orange', 'red'],
disabled=True
))
```


![Screenshot](assets/screenshots/multi_dropdown_disable.png)
11 changes: 11 additions & 0 deletions py/pkg/docs/dropdown_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,14 @@ def multi_dropdown_live(view: View): # height 3
),
f'You chose {choices}.'
)


# ## Disable
# Set `disabled=True` to disable.
def multi_dropdown_disable(view: View): # height 2
view(box(
'Choose some colors',
mode='multi menu',
options=['green', 'yellow', 'orange', 'red'],
disabled=True
))
3 changes: 2 additions & 1 deletion web/src/droplist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { BoxProps, make } from './ui';

export const Droplist = make(({ context, box }: BoxProps) => {
const
{ name, modes, text, placeholder, error, options: rawOptions, style } = box,
{ name, modes, text, placeholder, error, options: rawOptions, style, disabled } = box,
options = rawOptions ?? [],
required = modes.has('required'),
live = modes.has('live'),
Expand Down Expand Up @@ -53,6 +53,7 @@ export const Droplist = make(({ context, box }: BoxProps) => {
errorMessage={error}
required={required ? true : false}
onChange={onChange}
disabled={disabled === true}
/>
</div>
)
Expand Down

0 comments on commit e973aa2

Please sign in to comment.