Skip to content

fix(suggestion): preserve space input in editable triggers - #1999

Draft
lkxdsb wants to merge 1 commit into
ant-design:mainfrom
lkxdsb:codex/fix-suggestion-space-input
Draft

fix(suggestion): preserve space input in editable triggers#1999
lkxdsb wants to merge 1 commit into
ant-design:mainfrom
lkxdsb:codex/fix-suggestion-space-input

Conversation

@lkxdsb

@lkxdsb lkxdsb commented Jul 30, 2026

Copy link
Copy Markdown

🤔 This is a ...

  • 🐞 Bug fix
  • ✅ Test Case

🔗 Related Issues

Fixes #1873

💡 Background and Solution

When Suggestion wraps Sender, the editable control is rendered inside the Cascader trigger. Space key events can continue to the Cascader/rc-select keyboard handler, where Space is treated as a dropdown control key and its default behavior is prevented. As a result, the Sender cannot insert a space.

This PR adds a deliberately scoped compatibility fix in Suggestion:

  • stop plain Space from propagating when the real event target is an editable text input, textarea, or contenteditable element;
  • do not call preventDefault(), so native space insertion is preserved;
  • exclude disabled/read-only controls, non-text input types, and Alt/Ctrl/Meta shortcuts;
  • keep the existing arrow, Enter, and Escape navigation behavior unchanged.

This is not the root-cause fix in Cascader/rc-select. The underlying issue is that rc-select infers editability from its own mode and showSearch state instead of inspecting the actual event target inside a custom trigger. Fixing that behavior upstream requires a separate rc-select change and the subsequent Cascader/antd dependency release chain. This local guard resolves #1873 without waiting for that chain and can be reconsidered after an upstream fix is available.

Regression coverage includes the popup-open and popup-closed paths, the default Sender textarea, input slots, contenteditable slots, modifier shortcuts, and non-editable controls.

✅ Validation

  • npx jest --config .jest.js components/suggestion/__tests__/useActive.test.tsx components/suggestion/__tests__/index.test.tsx --runInBand --coverage=false --no-cache
    • 2 suites passed, 45 tests passed, 1 snapshot passed.
  • npx biome check packages/x/components/suggestion/useActive.ts packages/x/components/suggestion/__tests__/useActive.test.tsx packages/x/components/suggestion/__tests__/index.test.tsx
    • Passed.
  • npm run lint:script --workspace packages/x
    • Checked 540 files; passed with one existing unrelated warning in sender/hooks/use-speech.ts.
  • npx size-limit packages/x/dist/antdx.min.js --limit '520 KiB'
    • 523.25 kB brotlied, under the 532.48 kB limit.
  • Local browser verification: with the suggestion popup open, typing / followed by Space produces "/ ".

Local full tsc and declaration generation are currently blocked by four unrelated existing errors in components/attachments/index.tsx and components/file-card/components/ImageLoading.tsx; the focused type/lint/test paths for this change pass.

📝 Change Log

Language Changelog
🇺🇸 English Fix Suggestion preventing spaces from being entered in an editable Sender.
🇨🇳 Chinese 修复 Suggestion 包裹可编辑 Sender 时无法输入空格的问题。

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: de2adb32-6b57-4812-9b31-a5cb5c29af88

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion 快捷指令导致 Sender 无法输入空格

1 participant