Skip to content

Conversation

@DearAsutosh
Copy link

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have manually verified the behavior change locally.
  • If this is a new API or substantial change: the PR has an accompanying issue and the maintainers have approved on my working plan.

Motivation

This PR fixes a Windows-only issue where interactive CLI prompts lose
keyboard focus during create-docusaurus initialization.

The problem was caused by running readTemplates() and getSiteName()
concurrently using Promise.all() . On Windows terminals, concurrent
stdin access can cause arrow key input to be ignored until Enter is
pressed.

Test Plan

Since pnpm create docusaurus pulls the published package from the
registry, it does not reflect local source changes.

To test the fix locally:

  1. Built the package to compile TypeScript to JavaScript
  2. Ran the CLI directly using node bin/index.js
  3. Verified that interactive prompts accept arrow key input immediately
    on Windows 11 without requiring an extra Enter key press

This approach ensures the test runs against the locally modified CLI implementation.

Test links

N/A (CLI-only change, no UI impact)

Related issues/PRs

Fixes #11651

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Jan 8, 2026
@netlify
Copy link

netlify bot commented Jan 8, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit f7b0a07
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69601a1f1b78c600089400ae
😎 Deploy Preview https://deploy-preview-11652--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codayon
Copy link

codayon commented Jan 9, 2026

For some reason, with the same changes and rebuilding, the issue wasn't fixed on my end. Probably because I wasn't able to rebuild properly.

@DearAsutosh
Copy link
Author

Thanks for checking this !

Just to clarify the local testing steps I used, since this change won’t
be reflected when running pnpm create docusaurus from the registry.

After applying the patch, I rebuilt the local package and ran the CLI
directly:

  1. Build the package to compile TypeScript:
    yarn build

(or yarn workspace create-docusaurus build)

  1. Run the local CLI:
node packages/create-docusaurus/bin/index.js my-test-site

This ensures the test runs against the locally modified CLI code. Using
the published pnpm create docusaurus command will continue to use the
registry version and won’t reflect the fix.

Let me know if following these steps still reproduces the issue on your
end, happy to help further.

@codayon
Copy link

codayon commented Jan 9, 2026

node packages/create-docusaurus/bin/index.js my-test-site

Yeah, if I give the site name argument, the issue doesn't occur, otherwise it does.

@DearAsutosh
Copy link
Author

yeah,got it . when a site name is passed as an argument, the getSiteName() prompt is
skipped, so stdin is only initialized later during template/language
selection. In that case, the race condition doesn’t occur.

When no site name is provided, getSiteName() prompts earlier and stdin
is touched sooner, which likely explains why the issue can still be
reproduced in that path.

This PR removes one source of concurrent stdin access, but there may be
another stdin initialization path when the site name prompt is active.

readTemplates(),
getSiteName(reqName, rootDir),
]);
const templates = await readTemplates();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you help me understand where is the stdin access within the readTemplates method? I don't see any 😅

Copy link

@codayon codayon Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while i tried to debug myself, ai tried to convince me that, refactoring these lines will fix the issue. i was very naive and newbie to believe that.

Copy link
Author

@DearAsutosh DearAsutosh Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify what this change does solve :

Even though readTemplates() itself doesn’t access stdin, running it in parallel with getSiteName() changes the overall execution timing of the CLI startup. Making these steps sequential removes one source of concurrent work during the very early prompt initialization phase.

In my local testing on Windows, this reduced the likelihood of the terminal losing keyboard focus during the initial prompts, especially around template/language selection.

That said, I agree this doesn’t fully explain or eliminate all stdin issues - particularly when the site name prompt is active - so this change likely improves part of the behavior rather than addressing the entire root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CLI interactive prompts lose keyboard focus on Windows

3 participants