Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/@react-aria/combobox/src/useComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
keyboardDelegate: delegate,
disallowTypeAhead: true,
disallowEmptySelection: true,
autoFocus: 'first',
shouldFocusWrap,
ref: inputRef,
// Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component
Expand Down
5 changes: 4 additions & 1 deletion packages/@react-stately/combobox/src/useComboBoxState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ export function useComboBoxState<T extends object>(props: ComboBoxStateOptions<T

// Clear focused key when input value changes and display filtered collection again.
if (inputValue !== lastValue) {
selectionManager.setFocusedKey(null);
const firstKey = filteredCollection.getFirstKey();
if (firstKey) {
selectionManager.setFocusedKey(firstKey);
}
setShowAllItems(false);

// Set selectedKey to null when the user clears the input.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-aria-components/src/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function ComboBoxInner<T extends object>({props, collection, comboBoxRef: ref}:
style: {'--trigger-width': menuWidth} as React.CSSProperties,
clearContexts: CLEAR_CONTEXTS
}],
[ListBoxContext, {...listBoxProps, ref: listBoxRef}],
[ListBoxContext, {...listBoxProps, autoFocus: 'first', ref: listBoxRef}],
[ListStateContext, state],
[TextContext, {
slots: {
Expand Down