Skip to content

fix: suppress Sender borderless focus outline#1963

Open
QDyanbing wants to merge 1 commit into
ant-design:mainfrom
QDyanbing:fix-sender-borderless-focus
Open

fix: suppress Sender borderless focus outline#1963
QDyanbing wants to merge 1 commit into
ant-design:mainfrom
QDyanbing:fix-sender-borderless-focus

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Jul 3, 2026

Copy link
Copy Markdown

背景

ant-design/ant-design#58250 在 antd 侧为 borderless 输入类组件补充了 focus-visible outline,用于改善普通无边框输入控件的键盘焦点可见性。

Ant Design X 的 Sender 内部会使用 antd 的 Input.TextArea 和词槽 Input,并统一设置为 variant="borderless",但 Sender 本身已经有独立的容器、阴影和输入区域视觉。升级到包含该 antd 改动的版本后,Sender 内部输入在聚焦时会出现一条蓝色内部描边,和 Sender 设计不一致。

修改

  • 在 Sender 主输入 .ant-sender-input.ant-input-borderless 范围内去掉 antd 新增的 focus outline。
  • 在 Sender 词槽输入 .ant-sender-slot-input.ant-input-borderless 范围内同步去掉该 focus outline。
  • 覆盖只限定在 Sender 私有 class 下,不影响项目中其他 antd borderless 输入组件。

影响

该改动恢复 Sender 现有视觉表现,避免 antd borderless focus outline 穿透到 Sender 内部输入区域。普通 antd Input/Select 等 borderless 场景仍保留 antd 侧的无障碍焦点样式。

验证

  • npm run lint:style --workspace packages/x
  • npm test --workspace packages/x -- sender/__tests__/index.test.tsx sender/__tests__/slot.test.tsx --runInBand
  • antd lint packages/x/components/sender/style/index.ts --format json
  • antd lint packages/x/components/sender/style/slot-textarea.ts --format json
  • 本地浏览器验证 Sender textarea 和 slot input 聚焦后 outlineStyle 均为 none

Summary by CodeRabbit

  • Bug Fixes
    • 优化了发送框的无边框输入样式在聚焦时的显示,避免出现默认聚焦外轮廓。
    • 当输入框、文本域或其内部元素处于键盘聚焦状态时,自动隐藏 outline,视觉更统一。

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

本次变更在 Sender 组件的样式文件中新增了针对 borderless 输入框的聚焦样式控制,当元素或其内部 input/textarea 处于 focus-visible 状态时,移除默认的 outline 轮廓显示。

Changes

Borderless 输入焦点样式

Layer / File(s) Summary
Sender 组件 borderless focus 样式
packages/x/components/sender/style/index.ts, packages/x/components/sender/style/slot-textarea.ts
新增 antInputBorderlessCls 选择器常量,并在两个样式生成函数中添加对应规则,在 :focus-visible:has(input/textarea:focus-visible) 状态下将 outline 设置为 none

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

输入框边框虽已隐去,
聚焦光环也不再显现,
兔子轻轻敲下 outline: none,
一片静谧无扰的视界。
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次变更:抑制 Sender 的 borderless 聚焦轮廓。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the styling for the sender component and its slot-textarea to remove the default outline on focus-visible states when using borderless inputs. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@QDyanbing QDyanbing marked this pull request as ready for review July 3, 2026 09:26
@dosubot dosubot Bot added the bug Something isn't working label Jul 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/x/components/sender/style/slot-textarea.ts (1)

9-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

index.ts 中新增逻辑重复,建议抽取公共 mixin。

index.tsgenSenderStyle 中新增了几乎完全相同的 borderless focus-visible outline 规则(&${antCls}-input-borderless + &:focus-visible, &:has(input:focus-visible), &:has(textarea:focus-visible)outline: none)。两处逻辑重复,建议抽取为一个共享的样式生成函数(例如 genBorderlessFocusStyle(token)),分别在 genSenderStylegenSlotTextAreaStyle 中复用,避免后续修改时遗漏其中一处。

♻️ 抽取共享 mixin 示例
+// 可放置于共享的 util 文件,如 style/util.ts
+const genBorderlessFocusStyle = (antCls: string) => ({
+  [`&${antCls}-input-borderless`]: {
+    '&:focus-visible, &:has(input:focus-visible), &:has(textarea:focus-visible)': {
+      outline: 'none',
+    },
+  },
+});

之后在两处分别引用 ...genBorderlessFocusStyle(antCls) 展开即可。

Also applies to: 51-55

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/x/components/sender/style/slot-textarea.ts` at line 9, The
borderless focus-visible outline style is duplicated between
genSlotTextAreaStyle and genSenderStyle, so extract the shared rules into a
reusable helper such as genBorderlessFocusStyle(token/antCls) and reuse it from
both places. Keep the existing selectors for the borderless input class and
focus-visible states in that shared helper, then spread the result back into the
slot textarea and sender style generators so there is only one source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/x/components/sender/style/slot-textarea.ts`:
- Line 9: The borderless focus-visible outline style is duplicated between
genSlotTextAreaStyle and genSenderStyle, so extract the shared rules into a
reusable helper such as genBorderlessFocusStyle(token/antCls) and reuse it from
both places. Keep the existing selectors for the borderless input class and
focus-visible states in that shared helper, then spread the result back into the
slot textarea and sender style generators so there is only one source of truth.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ecfe8756-6a8c-4048-9c8e-d3e4dc92d938

📥 Commits

Reviewing files that changed from the base of the PR and between 841f8ed and 1919e6f.

📒 Files selected for processing (2)
  • packages/x/components/sender/style/index.ts
  • packages/x/components/sender/style/slot-textarea.ts

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant