Skip to content

[Bug] Autocomplete crash when initialValue is used #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
colinaaa opened this issue May 23, 2025 · 0 comments · Fixed by #328
Closed

[Bug] Autocomplete crash when initialValue is used #326

colinaaa opened this issue May 23, 2025 · 0 comments · Fixed by #328
Labels
bug Something isn't working

Comments

@colinaaa
Copy link

colinaaa commented May 23, 2025

Environment

  • OS: macOS
  • Node Version: v22.15.1
  • Package: @clack/prompts
  • Package Version: v1.0.0-alpha.0

Describe the bug

When initialValue is set, the prompts would crash with error: "TypeError: t.toLowerCase is not a function".

        const result = await p.autocomplete({
		message: 'Select a country',
		options: countries,
		placeholder: 'Type to search countries...',
		maxItems: 8,
+  	        initialValue: 'us',
	});

I think it's from one of these:

const label = (option.label ?? String(option.value ?? '')).toLowerCase();
const hint = (option.hint ?? '').toLowerCase();
const value = String(option.value).toLowerCase();
const term = searchText.toLowerCase();

To Reproduce

https://stackblitz.com/edit/node-xdxj5xxj?file=index.js

Steps to reproduce the behavior:

  • pnpm install
  • node index.js

Expected behavior

No crash happen.

Additional Information

Image
@colinaaa colinaaa added the bug Something isn't working label May 23, 2025
@github-project-automation github-project-automation bot moved this to Needs triage in Triage Board May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Needs triage
Development

Successfully merging a pull request may close this issue.

1 participant