Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion packages/@react-spectrum/picker/src/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ function Picker<T extends object>(props: SpectrumPickerProps<T>, ref: DOMRef<HTM
isRequired,
necessityIndicator,
menuWidth,
name
name,
autoFocus
} = props;

let {styleProps} = useStyleProps(props);
Expand Down Expand Up @@ -212,6 +213,7 @@ function Picker<T extends object>(props: SpectrumPickerProps<T>, ref: DOMRef<HTM
isQuiet={isQuiet}
isDisabled={isDisabled}
validationState={validationState}
autoFocus={autoFocus}
UNSAFE_className={classNames(styles, 'spectrum-Dropdown-trigger', {'is-hovered': isHovered})}>
<SlotProvider
slots={{
Expand Down
9 changes: 8 additions & 1 deletion packages/@react-spectrum/picker/stories/Picker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,14 @@ storiesOf('Picker', module)
<AsyncLoadingExample />
)
)
.add('resize', () => <ResizePicker />);
.add('resize', () => <ResizePicker />)
.add('autofocus', () => (
<Picker label="Test" autoFocus>
<Item key="One">One</Item>
<Item key="Two">Two</Item>
<Item key="Three">Three</Item>
</Picker>
));

function AsyncLoadingExample() {
interface Pokemon {
Expand Down
4 changes: 3 additions & 1 deletion packages/@react-types/select/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ export interface SpectrumPickerProps<T> extends AriaSelectProps<T>, SpectrumLabe
/**
* The name of the Picker input, used when submitting an HTML form.
*/
name?: string
name?: string,
/** Whether the element should receive focus on render. */
autoFocus?: boolean
}