Repository navigation
fix: Searched text is black in dark mode in select component - #55914
Conversation
|
|
👁 Visual Regression Report for PR #55914 Failed ❌
Important There are 1 diffs found in this PR: 🔄
|
Summary of ChangesHello @divyeshagrawal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a crucial style fix for the Select component, specifically targeting its behavior in dark mode. The change ensures that placeholder text is clearly visible by setting its color to white with a slight transparency, thereby enhancing the user experience and resolving a reported accessibility issue. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughSummary by CodeRabbit样式
✏️ Tip: You can customize this high-level summary in your review settings. 概述修改了 变更内容
代码审查工作量评估🎯 1 (简单) | ⏱️ ~5 分钟 需要关注的方面:
诗篇
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request aims to fix the placeholder color in the Select component for dark mode by increasing its opacity. The approach taken in components/select/style/index.ts has a critical flaw: it attempts to wrap an existing rgba color string within another rgba function, which results in invalid CSS. I've provided a comment with a suggested fix that uses an appropriate theme token (token.colorTextTertiary) to achieve the desired effect in a safe and theme-consistent way. This will resolve the visibility issue for the placeholder in both light and dark modes.
More templates
commit: |
Bundle ReportChanges will increase total bundle size by 56 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antd.min-array-pushAssets Changed:
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/select/style/index.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Always use TypeScript with strict type checking
Never useanytype - define precise types instead
Use interfaces (not type aliases) for object structures
Export all public interface types
Prefer union types over enums, useas constfor constants
Use early returns to improve readability
Support tree shaking
Follow import order: React → dependencies → antd components → custom components → types → styles
Prefer antd built-in components over external dependencies
Pass all ESLint and TypeScript checks
No console errors or warnings
**/*.{ts,tsx}: Use camelCase for property names
All components and functions must provide accurate type definitions
Avoid usinganytype, define types as precisely as possible
Use interface rather than type alias for defining object structures
All TypeScript should compile without errors or warnings
Use generics appropriately to enhance type flexibility
Use intersection types (&) to merge multiple types
Use literal union types to define limited option sets
Avoid using enum, prefer union types andas const
Rely on TypeScript's type inference as much as possible
Use type assertions (as) only when necessary
Complex data structures should be split into multiple interface definitions
Avoid outdated APIs and keep updated to new recommended usage
Files:
components/select/style/index.ts
components/**/style/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
components/**/style/*.ts: Use@ant-design/cssinjsfor all styling
Generate styles with functions namedgen[ComponentName]Style
Use design tokens from the Ant Design token system
Support both light and dark themes
Use CSS logical properties for RTL support (e.g.,margin-inline-startinstead ofmargin-left)
Respectprefers-reduced-motionfor animations
Files:
components/select/style/index.ts
components/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Never hardcode colors, sizes, or spacing values
components/**/*.{ts,tsx}: Use TypeScript and React for component development
Use functional components and hooks, avoid class components
Use PascalCase for component names
Use complete names rather than abbreviations in component naming
Initialize properties should usedefault+PropNamenaming pattern
Panel opening should useopenprop instead ofvisible
Event handlers should followon+EventNamenaming pattern
Child component events should followon+SubComponentName+EventNamenaming pattern
Components should provide arefattribute withnativeElementandfocusmethods
Export all public interface types for user convenience
Component props should use interface definition namedComponentNameProps
Use CSS transitions for simple animations, rc-motion for complex animations
Respect user's prefers-reduced-motion setting for animations
Follow WCAG 2.1 AA level accessibility standards for styling
Achieve 100% test coverage
UseuseLocalehook fromcomponents/locale/index.tsxto get localization configuration
Use React.memo, useMemo, and useCallback appropriately for performance optimization
UseReact.ForwardRefRenderFunctionfor component ref types
Callback function types should have explicit parameter and return value definitions
Component state should have dedicated interfaces (e.g., ComponentNameState)
Components should display well on different screen sizes (responsive design)
Components should support right-to-left (RTL) reading direction
Support page zoom to 200% with normal layout
Avoid animations that cause flickering
Ensure code runs normally with no console errors
Avoid unnecessary re-renders
Support Tree Shaking for bundle optimization
Files:
components/select/style/index.ts
**/*.{ts,tsx,md}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use 2-space indentation
Files:
components/select/style/index.ts
**/*.{ts,tsx,css}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Maintain cross-browser compatibility
Files:
components/select/style/index.ts
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js}: Use early returns to improve code readability
Pass all ESLint and TypeScript checks
Files:
components/select/style/index.ts
components/**/style/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Component Token naming format should follow:
variant (optional)+semantic part+semantic part variant (optional)+css property+size/disabled (optional)
Files:
components/select/style/index.ts
components/**/style/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
components/**/style/**/*.{ts,tsx}: Use@ant-design/cssinjsas the styling solution
Style generation functions should followgen[ComponentName]Stylenaming convention
Use CSS-in-JS with performance considerations, avoid unnecessary style recalculation
Use class selectors instead of tag selectors for style overrides to improve specificity
Use CSS logical properties (margin-inline-start) instead of directional properties (margin-left) for RTL support
Ensure sufficient color contrast and do not rely on color alone to convey information
Components should use global Tokens and component-level Tokens for styling
Avoid hardcoding colors, sizes, spacing values; use design Tokens instead
Component-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)
Token modifications should cascade downward to ensure design system consistency
All components must support dark mode
Provide clear visual indication for focus state
Files:
components/select/style/index.ts
🧠 Learnings (10)
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Avoid hardcoding colors, sizes, spacing values; use design Tokens instead
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Use design tokens from the Ant Design token system
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Component-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Components should use global Tokens and component-level Tokens for styling
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Token modifications should cascade downward to ensure design system consistency
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Ensure sufficient color contrast and do not rely on color alone to convey information
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/*.{ts,tsx} : Component Token naming format should follow: `variant (optional)` + `semantic part` + `semantic part variant (optional)` + `css property` + `size/disabled (optional)`
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Provide clear visual indication for focus state
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Support both light and dark themes
Applied to files:
components/select/style/index.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Use class selectors instead of tag selectors for style overrides to improve specificity
Applied to files:
components/select/style/index.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: build preview
- GitHub Check: test lib/es module (es, 1/2)
- GitHub Check: test lib/es module (es, 2/2)
- GitHub Check: test-react-latest (dom, 2/2)
- GitHub Check: build
- GitHub Check: test-react-latest (dom, 1/2)
- GitHub Check: test-node
- GitHub Check: test-react-legacy (18, 2/2)
- GitHub Check: test-react-legacy (18, 1/2)
- GitHub Check: lint
- GitHub Check: build
- GitHub Check: visual-diff snapshot (2/2)
- GitHub Check: visual-diff snapshot (1/2)
- GitHub Check: size
| inputPaddingHorizontalBase: token.calc(token.paddingSM).sub(token.lineWidth).equal(), | ||
| multipleSelectItemHeight: token.multipleItemHeight, | ||
| selectHeight: token.controlHeight, | ||
| colorTextPlaceholder: `rgba(${token.colorTextPlaceholder}, 0.5)`, |
There was a problem hiding this comment.
🧩 Analysis chain
Script executed:
#!/bin/bash
# First, let's examine the file and the context around line 155
echo "=== Content of components/select/style/index.ts around line 155 ==="
head -n 170 components/select/style/index.ts | tail -n 30
echo -e "\n=== Looking for SelectToken interface definition ==="
rg -n "interface SelectToken|type SelectToken" -A 20 components/select/style/index.ts
echo -e "\n=== Checking for colorTextPlaceholder definition ==="
rg -n "colorTextPlaceholder" -B 2 -A 2Repository: ant-design/ant-design
<shell_result>
Repository: ant-design/ant-design
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository ant-design/ant-design: Clone operation failed
</shell_result>
Ant Design v5 token system colorTextPlaceholder rgba opacity
<web_search_result>
Short answer: colorTextPlaceholder is an Ant Design v5 AliasToken you can set to any CSS color (including rgba) — it maps from the old @input-placeholder-color and controls input/placeholder appearance. To change placeholder opacity use an rgba() (or hsla()/8-digit hex) value when you set the token.
Example (ConfigProvider):
<ConfigProvider theme={{ token: { colorTextPlaceholder: 'rgba(0,0,0,0.38)' } }}>
...
Sources:
- Ant Design theme / customize-theme (tokens via ConfigProvider). [1]
- Mapping of old Less variable @input-placeholder-color → colorTextPlaceholder. [2]
- Example usage of overriding tokens (ConfigProvider examples). [3]
References:
[1] https://3x.ant.design/docs/react/customize-theme
[2] https://attach.w3cschool.cn/docsreactintroduce/ant-design-react-from-the-less-variable-to-the-design-token.html
[3] https://blog.csdn.net/qq_60178319/article/details/133684416
</web_search_result>
@ant-design/cssinjs rgba color utility functions
<web_search_result>
Short answer: @ant-design/cssinjs itself does not expose a dedicated "rgba" helper; Ant Design uses the @ant-design/fast-color package for color parsing/manipulation (including producing rgba/rgb strings and adjusting alpha). You can use FastColor to parse colors and output rgba (or modify alpha) in your cssinjs styles. [1][2]
Example (JS/TS):
- install: npm i @ant-design/fast-color
- usage:
const { FastColor } = require('@ant-design/fast-color');
const c = new FastColor('#1890ff');
c.toRgbString(); // "rgb(24,144,255)"
c.setAlpha(0.5); // (or new FastColor({ ... , a: 0.5 }))
c.toRgbString(true); // or c.toRgbString() with alpha support depending on version → "rgba(24,144,255,0.5)"
// use result in css-in-js style value
References:
- @ant-design/cssinjs package (mentions color utilities and related packages). [1]
- @ant-design/fast-color (API, parse/outputs like toRgbString/toHex and alpha support). [2]
Sources:
[1] @ant-design/cssinjs — npm package/readme.
[2] @ant-design/fast-color — npm package/readme.
</web_search_result>
Ant Design Select component dark mode placeholder color
<web_search_result>
Short answer — two options:
- Quick CSS override (works across versions)
- Target the placeholder element and set color + opacity (Ant uses opacity: 0.4 by default):
.ant-select-selection-placeholder { color: #cfcfcf; opacity: 1; } - If you use scoped CSS / CSS-in-JS, you may need a deep selector (e.g. ::v-deep or :global) to penetrate Ant’s styles. [1]
- Proper theming in antd v5 (preferred)
- Use ConfigProvider theme tokens. The placeholder color is governed by colorTextPlaceholder (alias/global token) and can also be set per-component under theme.components.Select. Example:
<ConfigProvider theme={{ token: { colorTextPlaceholder: '#cfcfcf' }, components: { Select: { /* component tokens */ } } }}>
...
- This respects darkAlgorithm / dark theme semantics. [2][3]
References:
- How to override Select placeholder (class & default opacity). [1]
- AntD token mapping (colorTextPlaceholder) and ConfigProvider theming (v5). [2][3]
</web_search_result>
Ant Design token format colorTextPlaceholder actual color value hex rgb
<web_search_result>
- Token: colorTextPlaceholder (alias for @input-placeholder-color). (attach.w3cschool.cn)
- Default (light theme, Ant Design): rgba(0, 0, 0, 0.35). Equivalent CSS forms:
- rgba: rgba(0, 0, 0, 0.35)
- 8‑digit hex: update uglify opts, transform unicode to ascii #59 (RRGGBBAA where AA = 0x59 ≈ 35% alpha)
- RGB (no alpha): not applicable (placeholder uses alpha); visual RGB over white ≈ rgb(89,89,89). (attach.w3cschool.cn)
If you want the exact value used in your build, tell me your antd version (e.g. 4.x or 5.x) and I’ll fetch the token source.
Citations:
- 1: https://attach.w3cschool.cn/docsreactintroduce/ant-design-react-from-the-less-variable-to-the-design-token.html?utm_source=openai
- 2: https://attach.w3cschool.cn/docsreactintroduce/ant-design-react-from-the-less-variable-to-the-design-token.html?utm_source=openai
</web_search_result>
Ant Design cssinjs fast-color how to apply alpha opacity to token
<web_search_result>
Short answer — parse the token with @ant-design/fast-color, then produce an rgba() string with the alpha you want (cssinjs will accept that string). Example:
-
Install: npm i @ant-design/fast-color
-
Parse token and build rgba with alpha:
import { FastColor } from '@ant-design/fast-color';
import { useStyleRegister } from '@ant-design/cssinjs';// inside style function where
token.colorPrimaryexists
const fc = new FastColor(token.colorPrimary); // parse token
const { r, g, b } = fc.toRgb(); // get rgb
const myAlpha = 0.5; // desired alpha 0..1
const colorWithAlpha =rgba(${r}, ${g}, ${b}, ${myAlpha});useStyleRegister('MyComp', () => ({
'.my': { color: colorWithAlpha },
}));
Notes:
- FastColor accepts hex8 / rgba / hsl inputs and returns toRgb() with r,g,b,a. Use those values to format rgba(...) with any alpha. (npmjs.com)
If you want the output as a hex8 string instead, convert r/g/b/a to hex with a tiny helper (or use a color util like tinycolor).
Citations:
- 1: https://www.npmjs.com/package/%40ant-design/fast-color?utm_source=openai
</web_search_result>
Ant Design Select component token colorTextPlaceholder implementation
<web_search_result>
Short answer: Ant Design's Select placeholder styling moved away from the alias token colorTextPlaceholder — the Select visuals (icons/placeholder) now use the quaternary text token (colorTextQuaternary) in recent changes. You can override it either by CSS (target .ant-select-selection__placeholder / .ant-select-selection-placeholder) or by overriding theme tokens for Select via ConfigProvider.theme (set the alias/component token such as colorTextQuaternary or the Select component token). [1][2][3]
Sources
- Figma / design update noting Select arrow/placeholder color change (colorTextPlaceholder → colorTextQuaternary). [1]
- Ant Design Select docs (component structure / placeholder element/class). [3]
- Community: how to style Select placeholder with .ant-select-selection__placeholder / .ant-select-selection-placeholder. [2]
- Ant Design theming / ConfigProvider token override docs (use theme.token and theme.components to override tokens). [4][5]
References
[1] Ant Design System for Figma — update note (change arrow color in Select from colorTextPlaceholder to colorTextQuaternary).
[2] StackOverflow — styling Select placeholder (.ant-select-selection__placeholder).
[3] Ant Design Select component docs.
[4] Ant Design theming / ConfigProvider token override examples.
[5] Ant Design design-token architecture / how component tokens are derived.
</web_search_result>
Ant Design dark mode colorTextPlaceholder token value dark algorithm
<web_search_result>
Short answer: colorTextPlaceholder is an alias that maps to colorTextQuaternary — in Ant Design’s theme generation the token colorTextPlaceholder = mergedToken.colorTextQuaternary (so under theme.darkAlgorithm its value is whatever the darkAlgorithm derives for colorTextQuaternary). [1]
Sources:
- Ant Design token mapping in the runtime theme bundle (shows colorTextPlaceholder -> mergedToken.colorTextQuaternary). [1]
- Ant Design docs on dark mode / theme algorithms (describes the darkAlgorithm deriving map/alias tokens). [2]
</web_search_result>
Ant Design Select placeholder dark mode issue white color
<web_search_result>
Short answer: override the Select placeholder element (.ant-select-selection-placeholder) and reset its default opacity (0.4). Example CSS for dark mode:
.ant-select .ant-select-selection-placeholder {
color: #bfbfbf !important; /* desired light-gray on dark bg */
opacity: 1 !important;
}
/* If using the dark theme wrapper (e.g. ConfigProvider dark / .ant-dark) scope it: */
.ant-dark .ant-select .ant-select-selection-placeholder {
color: #bfbfbf !important;
opacity: 1 !important;
}
Notes: the placeholder element is .ant-select-selection-placeholder (AntD v4+), and AntD applies opacity:0.4 by default so you must reset it. Use a scoped selector or :global / ::v-deep depending on your CSS setup to avoid style encapsulation issues. [1][2][3]
Sources:
[1] Ant Design — Dark Mode docs.
[2] Ant Design — Customize theme / style guidance.
[3] StackOverflow — styling Select placeholder (.ant-select-selection-placeholder) and default opacity.
</web_search_result>
Based on my verification through web search, I can now provide the final rewritten review comment:
Invalid CSS syntax—this will break placeholder styling in both light and dark modes.
The code produces invalid CSS. token.colorTextPlaceholder is already a complete color value (e.g., rgba(0, 0, 0, 0.35) in light mode), so wrapping it as rgba(${token.colorTextPlaceholder}, 0.5) generates "rgba(rgba(0, 0, 0, 0.35), 0.5)" or "rgba(#ffffff, 0.5)", both invalid. Browsers will ignore this value entirely, and the placeholder will not display.
Issues:
-
Critical: Syntax error—nested rgba/hex in rgba() is not valid CSS. Use
@ant-design/fast-colorto properly parse the token and construct a valid rgba string if opacity adjustment is needed:import { FastColor } from '@ant-design/fast-color'; const fc = new FastColor(token.colorTextPlaceholder); const { r, g, b } = fc.toRgb(); colorTextPlaceholder: `rgba(${r}, ${g}, ${b}, 0.5)`
-
Major: Hardcoded opacity—the
0.5value violates the token-based design approach. Use design tokens instead (e.g.,colorTextTertiaryorcolorTextQuaternaryif a less-visible placeholder is needed). -
Major: Misses the real issue—
colorTextPlaceholderis an alias forcolorTextQuaternaryand already receives the correct theme-aware color viadarkAlgorithm. The problem is likely the default opacity of0.4applied to placeholder elements. Fix the token value itself or adjust opacity separately, rather than wrapping the token.
🤖 Prompt for AI Agents
In components/select/style/index.ts around line 155, the current line wraps
token.colorTextPlaceholder inside rgba(...) which produces invalid CSS (e.g.
rgba(rgba(...), 0.5) or rgba(#fff, 0.5)); replace this by either using the
existing theme token (e.g., colorTextQuaternary or colorTextPlaceholder
directly) instead of wrapping it, or if you must change opacity, parse
token.colorTextPlaceholder with @ant-design/fast-color to extract r,g,b and
build a valid rgba(r, g, b, alpha) string and avoid hardcoding
opacity—preferably update the design token to expose the desired opacity rather
than manipulating the color string in place.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #55914 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 803 803
Lines 14812 14812
Branches 3913 3913
=========================================
Hits 14812 14812 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I think you misunderstood the issue feedback. It's not about fixing the placeholder color issue, but rather that the input box can input any text for search, and the entered text turns black. In dark mode, it's not visible what has been entered. This problem should be addressed. |
Oh! Yeah I completely misunderstood. Thanks for clarification! will work on the fix and update this PR |
| inputPaddingHorizontalBase: token.calc(token.paddingSM).sub(token.lineWidth).equal(), | ||
| multipleSelectItemHeight: token.multipleItemHeight, | ||
| selectHeight: token.controlHeight, | ||
| colorTextPlaceholder: `rgba(${token.colorTextPlaceholder}, 0.5)`, |
There was a problem hiding this comment.
直接给 input 加一个 color: inherit; 样式吧~
|
/gemini review |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where searched text within the Select component remains black in dark mode, making it unreadable. The fix correctly applies color: 'inherit' to the select input, resolving the problem for standard select components. My review includes one comment pointing out that this fix may not apply to the customize variant of the Select component due to the CSS selector used. I've suggested ensuring the fix is applied universally to all select variants for consistency.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/select/style/select-input.ts (1)
254-257: 考虑移除可能冗余的appearance: 'none'。在
::-webkit-search-cancel-button选择器中,第 255 行已经设置了display: 'none',这会完全隐藏该元素。在此情况下,第 256 行的appearance: 'none'可能是多余的,因为元素已经不可见了。如果没有特殊原因(例如,未来可能会改变
display属性),可以考虑移除第 256 行以保持代码简洁。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/select/style/select-input.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Always use TypeScript with strict type checking
Never useanytype - define precise types instead
Use interfaces (not type aliases) for object structures
Export all public interface types
Prefer union types over enums, useas constfor constants
Use early returns to improve readability
Support tree shaking
Follow import order: React → dependencies → antd components → custom components → types → styles
Prefer antd built-in components over external dependencies
Pass all ESLint and TypeScript checks
No console errors or warnings
**/*.{ts,tsx}: Use camelCase for property names
All components and functions must provide accurate type definitions
Avoid usinganytype, define types as precisely as possible
Use interface rather than type alias for defining object structures
All TypeScript should compile without errors or warnings
Use generics appropriately to enhance type flexibility
Use intersection types (&) to merge multiple types
Use literal union types to define limited option sets
Avoid using enum, prefer union types andas const
Rely on TypeScript's type inference as much as possible
Use type assertions (as) only when necessary
Complex data structures should be split into multiple interface definitions
Avoid outdated APIs and keep updated to new recommended usage
Files:
components/select/style/select-input.ts
components/**/style/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
components/**/style/*.ts: Use@ant-design/cssinjsfor all styling
Generate styles with functions namedgen[ComponentName]Style
Use design tokens from the Ant Design token system
Support both light and dark themes
Use CSS logical properties for RTL support (e.g.,margin-inline-startinstead ofmargin-left)
Respectprefers-reduced-motionfor animations
Files:
components/select/style/select-input.ts
components/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Never hardcode colors, sizes, or spacing values
components/**/*.{ts,tsx}: Use TypeScript and React for component development
Use functional components and hooks, avoid class components
Use PascalCase for component names
Use complete names rather than abbreviations in component naming
Initialize properties should usedefault+PropNamenaming pattern
Panel opening should useopenprop instead ofvisible
Event handlers should followon+EventNamenaming pattern
Child component events should followon+SubComponentName+EventNamenaming pattern
Components should provide arefattribute withnativeElementandfocusmethods
Export all public interface types for user convenience
Component props should use interface definition namedComponentNameProps
Use CSS transitions for simple animations, rc-motion for complex animations
Respect user's prefers-reduced-motion setting for animations
Follow WCAG 2.1 AA level accessibility standards for styling
Achieve 100% test coverage
UseuseLocalehook fromcomponents/locale/index.tsxto get localization configuration
Use React.memo, useMemo, and useCallback appropriately for performance optimization
UseReact.ForwardRefRenderFunctionfor component ref types
Callback function types should have explicit parameter and return value definitions
Component state should have dedicated interfaces (e.g., ComponentNameState)
Components should display well on different screen sizes (responsive design)
Components should support right-to-left (RTL) reading direction
Support page zoom to 200% with normal layout
Avoid animations that cause flickering
Ensure code runs normally with no console errors
Avoid unnecessary re-renders
Support Tree Shaking for bundle optimization
Files:
components/select/style/select-input.ts
**/*.{ts,tsx,md}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use 2-space indentation
Files:
components/select/style/select-input.ts
**/*.{ts,tsx,css}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Maintain cross-browser compatibility
Files:
components/select/style/select-input.ts
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js}: Use early returns to improve code readability
Pass all ESLint and TypeScript checks
Files:
components/select/style/select-input.ts
components/**/style/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Component Token naming format should follow:
variant (optional)+semantic part+semantic part variant (optional)+css property+size/disabled (optional)
Files:
components/select/style/select-input.ts
components/**/style/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
components/**/style/**/*.{ts,tsx}: Use@ant-design/cssinjsas the styling solution
Style generation functions should followgen[ComponentName]Stylenaming convention
Use CSS-in-JS with performance considerations, avoid unnecessary style recalculation
Use class selectors instead of tag selectors for style overrides to improve specificity
Use CSS logical properties (margin-inline-start) instead of directional properties (margin-left) for RTL support
Ensure sufficient color contrast and do not rely on color alone to convey information
Components should use global Tokens and component-level Tokens for styling
Avoid hardcoding colors, sizes, spacing values; use design Tokens instead
Component-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)
Token modifications should cascade downward to ensure design system consistency
All components must support dark mode
Provide clear visual indication for focus state
Files:
components/select/style/select-input.ts
🧠 Learnings (4)
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Ensure sufficient color contrast and do not rely on color alone to convey information
Applied to files:
components/select/style/select-input.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Use class selectors instead of tag selectors for style overrides to improve specificity
Applied to files:
components/select/style/select-input.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Provide clear visual indication for focus state
Applied to files:
components/select/style/select-input.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/*.{ts,tsx} : Follow WCAG 2.1 AA level accessibility standards for styling
Applied to files:
components/select/style/select-input.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
- GitHub Check: refuse
- GitHub Check: check-changelog
- GitHub Check: test lib/es module (es, 2/2)
- GitHub Check: test lib/es module (es, 1/2)
- GitHub Check: test lib/es module (lib, 2/2)
- GitHub Check: test-react-latest (dom, 1/2)
- GitHub Check: test-react-latest (dom, 2/2)
- GitHub Check: build
- GitHub Check: test-node
- GitHub Check: test-react-legacy (18, 2/2)
- GitHub Check: test-react-legacy (18, 1/2)
- GitHub Check: lint
- GitHub Check: visual-diff snapshot (2/2)
- GitHub Check: visual-diff snapshot (1/2)
- GitHub Check: build preview
- GitHub Check: size
- GitHub Check: build
🔇 Additional comments (2)
components/select/style/select-input.ts (2)
252-252: 注意:PR 标题与实际修复内容不一致。PR 标题提到"使选择框占位符颜色在深色模式下变为白色",但根据 Wxh16144 的评论和实际代码更改,真正的问题是输入的搜索文本在深色模式下显示为黑色,而不是占位符颜色的问题。
此修改(
color: 'inherit')正确地修复了输入文本颜色的问题,因为:
- 占位符是独立元素(第 155 行),有自己的颜色设置
token.colorTextPlaceholder- 此修改影响的是
${componentCls}-input元素,即用户输入时的文本颜色建议更新 PR 标题和描述,以准确反映修复的是"搜索输入文本颜色"而非"占位符颜色"。
252-252: Based on my verification through web search, I can now provide you with the rewritten review comment:
Verify that
token.colorTextcorrectly resolves to white/light color in dark mode.The addition of
color: 'inherit'at line 252 is the correct approach—it makes the input text inherit from the parent element's computed color (via the--select-colorCSS variable, which is set totoken.colorText). Since Ant Design'sdarkAlgorithmproperly derivestoken.colorTextas white/light in dark mode, this should resolve the black text issue you identified in the PR comments.The change at line 256 (
appearance: 'none'on the webkit-search-cancel-button) is not redundant; it complements thedisplay: 'none'on line 255. Both properties are needed:appearance: 'none'removes browser default styling, whiledisplay: 'none'removes the element from layout flow. This is the standard pattern for reliably hiding WebKit pseudo-elements across browsers.Actions:
- Confirm this renders correctly in both light and dark themes
- Test that placeholder text (line 155) and typed search text both appear with proper contrast




中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
📝 Change Log