You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CustomSelect: Adapt component for legacy props (WordPress#57902)
* Move components to own files
* Add legacy adapter
* Add legacy tests
* Update naming and remove unnecessary tests
* Add legacy props to adapter
* Create new component to forward store
* Create legacy component
* Remove useDeprecatedProps hook and update adapter
* Separate stories
* Update stories and types
* Convert function into variable instead
* Update legacy changeObject to match existing properties
* Add tests for onChange function
* add rest of legacy props
* Update sizing
* Memoize selected render value
* Remove deprecated prop to fix test failures
* Add `unmountOnHide` and require `defaultValue` as a result
See: ariakit/ariakit#3374 (comment)
* Update styling for experimental hint
* Connect CustomSelectButton to context system for legacy sizing
* Update sizing logic and types
* Fix styling to match legacy including hints
* Clean up props
* Omit ‘onChange’ from WordPressComponentProps to prevent conflict
* Update checkmark icon
* Update select arrow
* Update types
* Add static typing test
* Update story for better manual testing
* Control mount state for legacy keyboard behaviour
* Remove export that is no longer needed
* Update legacy onChange type
* Update tests
* Update naming
* Try mounting on first render to avoid required defaultValue
* Add WordPressComponentProps to default export
* Update types
* Replace RTL/userEvent with ariakit/test
* Remove unmountOnHide and related logic for first iteration
* Update docs
* Update naming
* Merge new tests and update to ariakit/test
* Fix typo in readme
* Legacy: Clean up stories
* Default: Clean up stories
* Add todo comment about BaseControl
* Fix styles
* Rename styled components for consistency
* Fix typo in readme
* Rename for clarity
* Update changelog
---------
Co-authored-by: brookewp <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: diegohaz <[email protected]>
Copy file name to clipboardexpand all lines: packages/components/src/custom-select-control-v2/README.md
+97-7
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,93 @@
1
+
# CustomSelect
2
+
1
3
<divclass="callout callout-alert">
2
4
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
3
5
</div>
4
6
5
-
### `CustomSelect`
6
-
7
7
Used to render a customizable select control component.
8
8
9
+
## Development guidelines
10
+
11
+
### Usage
12
+
13
+
#### Uncontrolled Mode
14
+
15
+
CustomSelect can be used in an uncontrolled mode, where the component manages its own state. In this mode, the `defaultValue` prop can be used to set the initial selected value. If this prop is not set, the first value from the children will be selected by default.
16
+
17
+
```jsx
18
+
constUncontrolledCustomSelect= () => (
19
+
<CustomSelect label="Colors">
20
+
<CustomSelectItem value="Blue">
21
+
{ /* The `defaultValue` since it wasn't defined */ }
22
+
<span style={ { color:'blue' } }>Blue</span>
23
+
</CustomSelectItem>
24
+
<CustomSelectItem value="Purple">
25
+
<span style={ { color:'purple' } }>Purple</span>
26
+
</CustomSelectItem>
27
+
<CustomSelectItem value="Pink">
28
+
<span style={ { color:'deeppink' } }>Pink</span>
29
+
</CustomSelectItem>
30
+
</CustomSelect>
31
+
);
32
+
```
33
+
34
+
#### Controlled Mode
35
+
36
+
CustomSelect can also be used in a controlled mode, where the parent component specifies the `value` and the `onChange` props to control selection.
CustomSelect is comprised of two individual components:
87
+
88
+
- `CustomSelect`: a wrapper component and context provider. It is responsible for managing the state of the `CustomSelectItem` children.
89
+
- `CustomSelectItem`: renders a single select item. The first `CustomSelectItem` child will be used as the `defaultValue` when `defaultValue` is undefined.
90
+
9
91
#### Props
10
92
11
93
The component accepts the following props:
@@ -16,37 +98,45 @@ The child elements. This should be composed of CustomSelect.Item components.
16
98
17
99
- Required: yes
18
100
19
-
##### `defaultValue`: `string`
101
+
##### `defaultValue`: `string| string[]`
20
102
21
103
An optional default value for the control. If left `undefined`, the first non-disabled item will be used.
22
104
23
105
- Required: no
24
106
107
+
##### `hideLabelFromVision`: `boolean`
108
+
109
+
Used to visually hide the label. It will always be visible to screen readers.
0 commit comments