diff --git a/.changeset/light-laws-judge.md b/.changeset/light-laws-judge.md new file mode 100644 index 0000000..145c5a6 --- /dev/null +++ b/.changeset/light-laws-judge.md @@ -0,0 +1,5 @@ +--- +'@clack/prompts': patch +--- + +feat: adaptative max items diff --git a/packages/prompts/src/index.ts b/packages/prompts/src/index.ts index 02e29d7..8d35bf0 100644 --- a/packages/prompts/src/index.ts +++ b/packages/prompts/src/index.ts @@ -8,7 +8,7 @@ import { SelectKeyPrompt, SelectPrompt, State, - TextPrompt + TextPrompt, } from '@clack/core'; import isUnicodeSupported from 'is-unicode-supported'; import color from 'picocolors'; @@ -69,7 +69,8 @@ const limitOptions = (params: LimitOptionsParams): string[] => const { cursor, options, style } = params; // We clamp to minimum 5 because anything less doesn't make sense UX wise - const maxItems = params.maxItems === undefined ? Infinity : Math.max(params.maxItems, 5); + const maxItems = + params.maxItems === undefined ? process.stdout.rows - 4 : Math.max(params.maxItems, 5); let slidingWindowLocation = 0; if (cursor >= slidingWindowLocation + maxItems - 3) {