Skip to content

Commit

Permalink
docs: Clarify and correct Select docs (#2684)
Browse files Browse the repository at this point in the history
This PR clarifies some vagueness in the v10 upgrade guide around Select, and it corrects some Select JSDoc typos

[category:Documentation]
  • Loading branch information
alanbsmith committed Apr 11, 2024
1 parent 29c68b2 commit f8ac333
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion modules/docs/mdx/10.0-UPGRADE-GUIDE.mdx
Expand Up @@ -263,6 +263,9 @@ We've converted `Select` into a
a flexible API and access to its internals via its subcomponents.

```tsx
import {Select} from '@workday/canvas-kit-react/select';
import {FormField} from '@workday/canvas-kit-react/form-field';

// v9
<FormField label="Pizza Size">
<Select onChange={handleChange} value={value}>
Expand All @@ -274,6 +277,9 @@ a flexible API and access to its internals via its subcomponents.
```

```tsx
import {Select} from '@workday/canvas-kit-react/select';
import {FormField} from '@workday/canvas-kit-react/form-field';

// v10
<Select items={['Small', 'Medium', 'Large']}>
<FormField label="Pizza Size" inputId="pizza">
Expand All @@ -291,7 +297,13 @@ a flexible API and access to its internals via its subcomponents.
</Select>
```

Unlike the
Notice that `Select` is now outside the `FormField`. This is due to the update in `Select` and how
the `FormField` in main applies attributes. Previously, `Select` was a styled native `<select>`
input and `FormField` applied attributes automatically to that input. The new `Select` is solely a
React context provider for its subcomponents. `FormField` needs `Select.Input` to be a direct child
to apply attributes correctly.

Also, unlike the
[Select in Preview](https://workday.github.io/canvas-kit/?path=/story/preview-select-left-label--default),
this component does not have a border around its menu.

Expand Down
8 changes: 4 additions & 4 deletions modules/react/select/lib/Select.tsx
Expand Up @@ -172,7 +172,7 @@ export const Select = createContainer()({
* `Select.Popper` renders a {@link ComboboxPopper Combobox.Menu.Popper}. You have access to all `Popper` props.
*
* ```tsx
* <Select item={options}>
* <Select items={options}>
* <FormField label="Your Label">
* <Select.Input onChange={(event) => handleChange(event)}>
* <Select.Popper>
Expand All @@ -189,7 +189,7 @@ export const Select = createContainer()({
* **Note: The card will be the width of its corresponding `Select.Input`**.
*
* ```tsx
* <Select item={options}>
* <Select items={options}>
* <FormField label="Your Label">
* <Select.Input onChange={(event) => handleChange(event)}>
* <Select.Popper>
Expand All @@ -206,7 +206,7 @@ export const Select = createContainer()({
* `Select.List` renders a {@link ComboboxMenuList Combobox.Menu.List}. You have access to all `ListBox` props.
*
* ```tsx
* <Select item={options}>
* <Select items={options}>
* <FormField label="Your Label">
* <Select.Input onChange={(event) => handleChange(event)}>
* <Select.Popper>
Expand All @@ -225,7 +225,7 @@ export const Select = createContainer()({
* `Select.Item` renders a {@link ComboboxMenuItem Combobox.Menu.Item} with aria role of `option`. You can optionally render a `Icon`.
*
* ```tsx
* <Select item={options}>
* <Select items={options}>
* <FormField label="Your Label">
* <Select.Input onChange={(event) => handleChange(event)}>
* <Select.Popper>
Expand Down

0 comments on commit f8ac333

Please sign in to comment.