Skip to content

Commit

Permalink
feat(select): set default cursorPosition to the first non-disabled it…
Browse files Browse the repository at this point in the history
…em (#1170)
  • Loading branch information
zonemeen committed Oct 4, 2022
1 parent 3202395 commit 58223c9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/select/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ type SelectConfig = AsyncPromptConfig & {

export default createPrompt<string, SelectConfig>((config, done) => {
const { choices } = config;
const startIndex = Math.max(
choices.findIndex(({ disabled }) => !disabled),
0
);

const paginator = useRef(new Paginator()).current;
const firstRender = useRef(true);

const prefix = usePrefix();
const [status, setStatus] = useState('pending');
const [cursorPosition, setCursorPos] = useState(0);
const [cursorPosition, setCursorPos] = useState(startIndex);

useKeypress((key) => {
if (isEnterKey(key)) {
Expand Down

0 comments on commit 58223c9

Please sign in to comment.