Skip to content

Commit

Permalink
Fixes #11270. Adds support for marking options within a `SelectContro…
Browse files Browse the repository at this point in the history
…l` as 'disabled', which translates to the `disabled` attribute being added to the HTML `option` element.
  • Loading branch information
philipjohn authored and gziolo committed Aug 29, 2019
1 parent a8663e9 commit b5e3950
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/block-library/src/tag-cloud/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class TagCloudEdit extends Component {
const selectOption = {
label: __( '- Select -' ),
value: '',
disabled: true,
};
const taxonomyOptions = map( taxonomies, ( taxonomy ) => {
return {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/select-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Render a user interface to select multiple users from a list.
value={ this.state.users } // e.g: value = [ 'a', 'c' ]
onChange={ ( users ) => { this.setState( { users } ) } }
options={ [
{ value: null, label: 'Select a User', disabled: true },
{ value: 'a', label: 'User A' },
{ value: 'b', label: 'User B' },
{ value: 'c', label: 'User c' },
Expand All @@ -115,7 +116,6 @@ Render a user interface to select multiple users from a list.

### Props


- The set of props accepted by the component will be specified below.
- Props not included in this set will be applied to the select element.
- One important prop to refer is `value`. If `multiple` is `true`, `value` should be an array with the values of the selected options.
Expand Down Expand Up @@ -150,6 +150,7 @@ If this property is added, multiple values can be selected. The value passed sho
An array of objects containing the following properties:
- `label`: (string) The label to be shown to the user.
- `value`: (Object) The internal value used to choose the selected value. This is also the value passed to onChange when the option is selected.
- `disabled`: (boolean) Whether or not the option should have the disabled attribute.
- Type: `Array`
- Required: No

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/select-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function SelectControl( {
<option
key={ `${ option.label }-${ option.value }-${ index }` }
value={ option.value }
disabled={ option.disabled }
>
{ option.label }
</option>
Expand Down

0 comments on commit b5e3950

Please sign in to comment.