Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify that open state can be set to get default-opened behavior #236

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions research/src/pages/select/select.proposal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ then select the appropriate one for you.

## &lt;select&gt; Properties <a href="#select-properties" id="select-properties"></a>

| Attribute Name | Type | Default Value | Description | |
| Property Name | Type | Default Value | Description | |
| ------------------------------------------------------------------------------------------------------- | ----------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --- |
| `autocomplete` | `string` | `off` | Allows the developer to provide a hint on how to search the content within the `<option>`(s) | |
| [`autofocus`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/autofocus) | `bool` | `false` | If set to `true` the `input` will have focus set on page load | |
Expand All @@ -38,6 +38,7 @@ then select the appropriate one for you.
| `length` | `int` | `0` | The number of `<option>` elements in the `<select>` element | |
| `multiple` | `bool` | `false` | If set to true this will allow more than one `<option>` | |
| `name` | `string` | `null` | Represents the name of the control | |
| `open` | `bool` | `false` | A `boolean` that indicates whether the `<select>` is in the [`open`](#open-state) state | |
| [`options`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/options) | `HTMLOptionsCollection` | | Returns a `HTMLOptionsCollection` of the `<option>` elements contained by the `<select>` element | |
| `required` | `bool` | `false` | A value must be provided for the control if set to `true` | |
| [`selectedIndex`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/selectedIndex) | `int` | `-1` | The index of the first or last selected `<option>` element, depending on the value of `multiple` | |
Expand Down Expand Up @@ -184,12 +185,18 @@ and is therefore considered to be invalid.

**Default State**

- Show the currently selected `<option>` or the first `<option>`
- When the user invokes the `button` by:
- The `selected-value` part should show the currently selected `<option>` or the first `<option>`.
- The `listbox` part is not visible to the user.
- The state of the `<select>` is set to `open` when the user invokes the `button` by:
- a [pointerup](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/pointerup_event) or
[click](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event) event is fired
- the user presses the `space` or `enter` key
- The state of the `<select>` is set to `open`

<p class="note">
If an author wants a &lt;select&gt; to be open by default, they can set the &lt;select&gt;'s
`open` property to true in the JavaScript responsible for initializing the component, or in HTML
set the &lt;select&gt;'s `open` boolean content attribute, which reflects the `open` property.
</p>

**Open State**

Expand Down