-
Notifications
You must be signed in to change notification settings - Fork 284
Fix get bounding react #3368
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
base: feat_v3.x
Are you sure you want to change the base?
Fix get bounding react #3368
Conversation
* fix: 暂时屏蔽掉css transition * fix: cpp 下class类问题
* chore(release): v3.0.18 * fix(swiper): duration属性透传 (jdf2e#3337) * feat: 修复属性透传 * feat: 直接删除duration * fix(range): taro环境异步渲染useReady不会触发 (jdf2e#3297) * fix(range): taro环境异步渲染useReady不会触发 * refactor: 将组件中使用的useReady替换为useLayoutEffect * chore: 升级版本号 * feat(popup): 增加上下滑动修改高度 * fix(input): 兼容h5和小程序获取原生input标签 (jdf2e#3341) * feat: inputRef获取真实input-dom * feat: 兼容小程序和h5获取input标签 * feat: 取消?问好,出错直接抛出 * feat(Popup): 新增弹层可上下滑动 (jdf2e#3340) * feat: 支持popup 高度可以伸缩 * feat: 适配小程序 * feat: 修改文档 * fix: 默认值不需要,走样式 * feat: 增加使用的限制条件 * docs: 增加文档 * fix: 适配鸿蒙,初始值重置修改 * test: 添加单测 * fix: 增加h5 的初始值 * fix: 增加高度下限约束 * test: fix 单测 * feat(popup): 添加自定义顶部 * fix(input): taro 下只读可以点击 --------- Co-authored-by: Alex.hxy <[email protected]> Co-authored-by: YONGQI <[email protected]> Co-authored-by: RyanCW <[email protected]>
* feat: 鸿蒙适配td * chore: 强制指向某些版本 * fix: swipe 在鸿蒙下不好使的问题 * fix(toast): 无法在鸿蒙下换行的问题 * fix: 调整滑动时动效时间 * fix: 去掉注释 * chore: 升级nutui版本 * chore: 升级版本号 * fix: lint
Walkthrough本次变更包含:新增 Popup 的 top 插槽能力并相应更新样式/类型/文档;多处 Taro 组件从 useLayoutEffect 迁移到 useReady/nextTick;去除 Taro 端 Dialog/Overlay/Popup 的 CSSTransition 过渡;大量 SCSS 引入 dynamic 条件分支;主题变量与类型扩展;若干组件的小型行为与样式调整。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant P as Popup
participant O as Overlay
participant T as Top(Node)
participant M as Measure(getRect/nextTick)
U->>P: set visible = true, pass top
P->>O: render overlay (visible)
P->>P: render content
alt has top
P->>T: render top container
P->>M: nextTick -> measure popup height
M-->>P: height
P->>T: set bottom offset = height
end
U->>P: set visible = false
P->>O: hide via display:none
sequenceDiagram
autonumber
participant U as User
participant N as NoticeBar(Taro)
participant ID as useUuid
participant M as getRectInMultiPlatform
participant S as State
U->>N: mount
N->>ID: create wrapRefId/contentRefId
N->>M: measure wrap/content by id
M-->>N: rects
N->>S: set scroll params/visibility
U->>N: click right icon
N->>S: toggle show, call onClose/close
Estimated code review effort🎯 4 (Complex) | ⏱️ ~70 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug related to getBoundingClientRect
functionality in Taro environments and implements various style and component improvements. The fix addresses compatibility issues by replacing direct usage of Taro.ENV_TYPE
with a local constant definition.
- Replaces
Taro.ENV_TYPE
with localENV_TYPE
constant in utility functions - Adds a new
top
property to popup components for displaying content above the title - Updates various SCSS files with conditional display properties for dynamic environments
Reviewed Changes
Copilot reviewed 67 out of 68 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/utils/taro/get-rect-by-id.ts | Defines local ENV_TYPE constant to replace Taro.ENV_TYPE usage |
src/types/spec/popup/base.ts | Adds top property to BasePopup interface |
src/packages/popup/*.tsx | Implements top property rendering in popup components |
src/packages/input/input.taro.tsx | Replaces Taro.ENV_TYPE with local ENV_TYPE constant |
Multiple SCSS files | Adds conditional display properties for dynamic environments |
src/styles/*.scss | Updates font sizes, weights, and design tokens |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
const ENV_TYPE = { | ||
WEAPP: 'WEAPP', | ||
SWAN: 'SWAN', | ||
ALIPAY: 'ALIPAY', | ||
TT: 'TT', | ||
QQ: 'QQ', | ||
JD: 'JD', | ||
WEB: 'WEB', | ||
RN: 'RN', | ||
HARMONY: 'HARMONY', | ||
QUICKAPP: 'QUICKAPP', | ||
} | ||
|
||
export const getRectById = (id: string) => { | ||
return new Promise((resolve, reject) => { | ||
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) { | ||
if (Taro.getEnv() === ENV_TYPE.WEB) { |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ENV_TYPE constant duplicates values from Taro.ENV_TYPE. Consider importing the constant from Taro instead of redefining it locally, or add a comment explaining why this duplication is necessary for the bug fix.
Copilot uses AI. Check for mistakes.
const ENV_TYPE = { | ||
WEAPP: 'WEAPP', | ||
SWAN: 'SWAN', | ||
ALIPAY: 'ALIPAY', | ||
TT: 'TT', | ||
QQ: 'QQ', | ||
JD: 'JD', | ||
WEB: 'WEB', | ||
RN: 'RN', | ||
HARMONY: 'HARMONY', | ||
QUICKAPP: 'QUICKAPP', | ||
} |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ENV_TYPE constant is duplicated across multiple files. Consider extracting it to a shared utility file to maintain consistency and reduce duplication.
Copilot uses AI. Check for mistakes.
| minHeight | 设置最小高度 | `string` | `26%` | | ||
| left | 标题左侧部分 | `ReactNode` | `-` | | ||
| title | 标题中间部分 | `ReactNode` | `-` | | ||
| top | 頂部佔位 | `ReactNode` | `-` | |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent language mixing - contains Traditional Chinese characters. Should use Simplified Chinese to match the rest of the documentation.
| top | 頂部佔位 | `ReactNode` | `-` | | |
| top | 顶部占位 | `ReactNode` | `-` | |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (6)
src/packages/button/button.taro.tsx (2)
29-46
: 修复类型定义与实际行为的不一致。存在以下问题:
nativeType
属性无效:接口中声明了nativeType: 'submit' | 'reset'
,但在渲染时(Line 160)该属性被注释掉,实际上不会生效。这会误导使用者,让他们认为可以通过此属性控制按钮的表单行为。
onClick
类型不匹配:声明为MouseEvent<HTMLButtonElement>
,但实际上组件渲染为View
(Line 157),触发的事件类型与声明不符。缺失小程序按钮属性:移除
OmitMiniProgramButtonProps
意味着失去了小程序原生按钮的所有特性(如open-type
、form-type
等),这可能是破坏性变更。建议的修复方案:
方案 1(推荐):如果确实需要使用
View
而非原生按钮,应该更新类型定义以反映实际行为:-export interface ButtonProps extends BasicComponent { +export interface ButtonProps extends BasicComponent { color: string shape: ButtonShape type: ButtonType size: ButtonSize fill: ButtonFill block: boolean loading: boolean disabled: boolean icon: React.ReactNode rightIcon: React.ReactNode - nativeType: 'submit' | 'reset' // | 'button' - onClick: (e: MouseEvent<HTMLButtonElement>) => void + onClick: (e: MouseEvent<HTMLDivElement>) => void }方案 2(如需表单功能):恢复使用
TaroButton
以支持表单提交和原生按钮特性。
156-182
: src/packages/button/button.taro.tsx 第156–182行:保持按钮语义与功能
切换<TaroButton>
→<View>
导致:
- 丢失原生按钮语义与键盘交互(空格、回车),违反 WCAG
- 注释
formType/nativeType
,无法触发表单提交(demo/测试仍使用nativeType="submit"
)- forwardRef 类型声明
HTMLButtonElement
与<View>
不匹配建议:
- 恢复
<TaroButton>
或在<View>
上补全role="button
、tabIndex
、键盘事件及aria-disabled
,并更新 ref 类型- 如需支持表单提交,重新传递并处理
formType/nativeType
请说明此变更原因并修复。
src/packages/range/range.taro.tsx (1)
534-536
: className 多了一个右花括号,导致渲染类名错误字符串模板末尾有多余的
}
,会渲染出非法类名,需立即修复。- className={`${classPrefix}-bar ${isHm ? '' : `${classPrefix}-bar-animate`}}`} + className={`${classPrefix}-bar ${isHm ? '' : `${classPrefix}-bar-animate`}`}src/packages/lottie/lottiemp.taro.tsx (1)
90-90
: Canvas 属性拼写错误:应为 disableScroll/disable-scroll当前使用了
disalbeScroll
/disalbe-scroll
(拼写错误),会导致属性不生效。// WEAPP/JD 分支 - disalbeScroll + disableScroll // 其它分支 - disalbe-scroll + disable-scrollAlso applies to: 100-100
src/packages/noticebar/noticebar.taro.tsx (1)
128-143
: 修复跨端计时器泄漏并移除 H5 限定写法(window.setInterval)
- 使用
window.setInterval
会在非 H5 端(小程序等)报错;并且当前clearInterval(timer)
位于未依赖timer
的 effect 清理中,存在清不掉的泄漏风险。- 方案:用
useRef
持有定时器句柄,统一用全局setInterval/clearInterval
,在开始前与卸载时都清理。可直接应用如下补丁:
@@ - useEffect(() => { + useEffect(() => { if (isVertical) { @@ - return () => { - // 销毁事件 - clearInterval(timer) - } + return () => { + // 销毁事件 + if (timerRef.current) { + clearInterval(timerRef.current) + timerRef.current = null + } + } }, [childs]) @@ - const startRollEasy = () => { + const startRollEasy = () => { + if (timerRef.current) { + clearInterval(timerRef.current) + timerRef.current = null + } showhorseLamp() const time = height / speed / 4 < 1 ? Number((height / speed / 4).toFixed(1)) * 1000 : ~~(height / speed / 4) * 1000 - const timerCurr = window.setInterval(showhorseLamp, time + Number(duration)) - SetTimer(timerCurr) + const timerCurr = setInterval(showhorseLamp, time + Number(duration)) + timerRef.current = timerCurr as unknown as number }并在组件内添加句柄(选段外新增):
// 选段外新增:与其它 ref 靠近 const timerRef = useRef<number | null>(null)这样在任意端(H5/小程序)均可运行且不会泄漏。
Also applies to: 197-205
src/packages/popup/popup.taro.tsx (1)
333-355
: 验证移除 CSSTransition 后的过渡回调处理。当前实现移除了
CSSTransition
,改用简单的display
样式切换。这导致以下问题:
过渡回调未调用:组件接收
afterShow
和afterClose
回调 props(第 88-89 行),但在新实现中不再调用它们。如果外部代码依赖这些回调,将导致功能缺失。无过渡动画:移除
CSSTransition
意味着弹窗显示/隐藏不再有过渡动画效果,这可能影响用户体验。请确认:
- 是否有意移除过渡动画?
- 如果
afterShow
/afterClose
仍需支持,应在适当时机调用它们(如在open()
/close()
函数中,或使用其他生命周期钩子)运行以下脚本检查 afterShow/afterClose 的使用情况:
#!/bin/bash # 检查 afterShow 和 afterClose 在代码库中的使用 rg -n --type=tsx --type=ts --type=jsx --type=js -C 3 'afterShow|afterClose' -g '!node_modules' -g '!dist' -g '!build'
🧹 Nitpick comments (23)
src/packages/divider/divider.scss (1)
48-53
: 动态分支将 display 从 inline-flex 切到 flex,可能影响内联对齐
- vertical-align: middle 仅对 inline/inline-block/table-cell 生效;在 dynamic 分支使用 flex(块级)后,该对齐可能失效,.nut-divider-vertical 在文本/内联容器中可能出现错位。
- 建议:两端统一为 inline-flex,或在 dynamic 分支补偿对齐策略(例如保持 inline-flex,或改用 inline-block 并确认高度/边距),并在 H5/微信小程序等端验证内联场景。
如确因端能力限制必须用 flex,请补充原因与用例,并附上回归检查用例(文本内作为分隔、Flex 布局内行内放置、与图标/字串对齐)。
参考修正(保持一致行为):
-/* #ifdef dynamic*/ -display: flex; -/* #endif */ +/* #ifdef dynamic*/ +display: inline-flex; +/* #endif */同时可考虑统一条件注释的空格风格以便预处理器与代码风格一致(可选)。
src/packages/segmented/segmented.scss (1)
2-7
: 动态分支从 inline-flex 切换为 flex,需确认布局语义影响与构建配置
- dynamic 构建下 display 由 inline-flex 变为 flex,会从行内级盒变为块级盒,可能影响与相邻元素的排布(换行、占宽、对齐)。请确认现有使用场景(内联放置、与文字或图标同行等)不受影响,或提供明确修饰类(如 .nut-segmented--inline / --block)供业务显式选择,以避免隐式行为变化。
- 条件编译注释语法看起来符合 Taro 习惯,但请确认样式链路会处理 /* #ifdef dynamic / 与 / #ifndef dynamic */,且执行在压缩/去注释之前,并确保 dynamic 宏已在构建中显式定义。
如需降低回归风险,可考虑仅在外层容器切换 display,组件内部保持 inline-flex 语义不变,或在文档/迁移指南中标注该差异。
src/packages/skeleton/skeleton.scss (1)
7-12
: 条件编译写法建议合并为 #else,并请确认样式预处理是否生效当前把两段 display 分别包在
#ifndef dynamic
与#ifdef dynamic
中。若构建链未对 SCSS 做条件编译(或未定义 dynamic),两条声明都会保留,最终以后者display: flex
生效,可能引入 H5/文档站的回归(原行为 inline-flex)。建议用
#else
保证互斥,降低误配风险:- /* #ifndef dynamic*/ - display: inline-flex; - /* #endif */ - /* #ifdef dynamic*/ - display: flex; - /* #endif */ + /* #ifndef dynamic*/ + display: inline-flex; + /* #else */ + display: flex; + /* #endif */另请确认:
- SCSS 确实经过条件编译预处理(这些指令在样式侧会被处理,而非仅在 JS 中)。
- dynamic 在各目标(H5/小程序)均有明确配置,避免默认落到 flex 导致布局从“行内”变“块级”。
src/packages/steps/steps.taro.tsx (3)
38-46
: 避免重复计算 Children 个数,提取为局部常量。当前在 classNames 与 cloneElement 中多次调用 React.Children.count(children)。可读性与微小性能更优:先计算一次复用。
const classPrefix = `nut-steps` - const classes = classNames( + const childrenCount = React.Children.count(children) + const classes = classNames( classPrefix, { [`${classPrefix}-${direction}`]: true, - [`${classPrefix}-${direction}-count-${React.Children.count(children)}`]: true, + [`${classPrefix}-${direction}-count-${childrenCount}`]: true, [`${classPrefix}-${direction}-${layout}`]: true, [`${classPrefix}-${direction}-${type}`]: true, [`${classPrefix}-${direction}-${status}`]: true, }, className ) ... - 'nut-step-last': index === React.Children.count(children) - 1, + 'nut-step-last': index === childrenCount - 1,Also applies to: 56-58
55-59
: 移除 @ts-ignore,通过更准确的类型守卫。使用 React.isValidElement<{ className?: string }>(child) 作为类型收窄,避免忽略类型检查。
- if (React.isValidElement(child)) { + if (React.isValidElement<{ className?: string }>(child)) { return React.cloneElement(child, { - // @ts-ignore className: classNames(child.props.className, { 'nut-step-last': index === childrenCount - 1, }), })
51-64
: Taro 端元素建议核实是否应使用 View 而非 div。在 *.taro.tsx 中直接使用 div 对小程序端可能不兼容;若项目规范在 Taro 端统一用 @tarojs/components 的 View,请考虑切换或确认此处仅用于 H5。
能否确认该文件在小程序端的渲染路径与项目约定?若需,我可按现有模式批量生成替换 PR 草案。
src/packages/cascader/cascader.scss (1)
14-16
: 动态编译包裹 flex:请确认 dynamic 构建下布局与兼容性,并统一指令注释格式
- 功能确认:在 dynamic 构建中会移除
flex: initial
,可能回落到 Tabs 默认的flex: 1
(若存在),导致标题项被拉伸。请在 H5/各小程序端实际验证布局是否符合预期;如需固定不拉伸,可在 dynamic 分支明确指定期望的 flex 值或提高选择器优先级覆盖。- 兼容性建议:部分小程序/内核对
flex: initial
支持不一致,flex: 0 0 auto
更稳妥,可考虑替换以减少端差异。- 细节优化:注释指令格式与项目其它处保持一致,补充空格以提升可读性。
建议最小修正(仅格式一致性):
- /* #ifndef dynamic*/ + /* #ifndef dynamic */src/packages/virtuallist/virtuallist.scss (1)
37-41
: 可选:用 SCSS 条件代替注释指令,减少对构建链顺序的依赖若可在 SCSS 层引入编译期变量,建议改为 SCSS 条件:
@if not $dynamic { overflow: auto; }另外,注释格式可统一为“/* #ifndef dynamic / … / #endif */”以便后续工具识别(当前首段注释缺少空格)。
src/packages/elevator/elevator.scss (2)
19-22
: 动态构建下移除 overflow: auto 可能影响可滚动性,请验证父容器 .nut-elevator-list 已有 overflow: hidden;在 dynamic 分支不设置内层 overflow 时,长列表可能无法滚动或依赖 JS 滚动容器。请在 H5/微信小程序动态模式下验证长列表能正常滚动、吸顶分组不抖动。若需要保留内层滚动,建议在非 dynamic 的同时加入惯性滚动优化;dynamic 分支请明确滚动容器归属(父/子)并在实现中统一。
可选优化(非功能性,提升 iOS 滚动体验):
- /* #ifndef dynamic*/ - overflow: auto; - /* #endif */ + /* #ifndef dynamic*/ + overflow: auto; + -webkit-overflow-scrolling: touch; + /* #endif */
101-106
: inline-flex 与 flex 的差异需确认;可简化条件写法以减少重复
- 行为差异:inline-flex 是内联级盒,可能影响基线/换行与点击区域;flex 为块级。请确认在 dynamic 与非 dynamic 下,条目对齐、间距与点击热区一致。
- 建议精简:默认使用 display: flex,仅在非 dynamic 下覆盖为 inline-flex,等价但减少重复条件块。
- /* #ifndef dynamic*/ - display: inline-flex; - /* #endif */ - /* #ifdef dynamic*/ - display: flex; - /* #endif */ + display: flex; + /* #ifndef dynamic*/ + display: inline-flex; + /* #endif */src/packages/toast/toast.scss (2)
95-103
: 在 harmony 动态分支放置 height:auto 以保持意图一致(或确认需全端生效)当前 height:auto 未受条件编译保护;如果只想在 harmony dynamic 下放宽排版,建议把它移入同一 #ifdef 块,和行高覆盖保持一致。若确需全端生效,可忽略本建议,但请确认不会影响其他端的多行排版与居中对齐。
建议改动:
请本地核对多行文本、有/无图标场景在各端的视觉是否一致(尤其顶部/中部定位与垂直居中)。
&-text { color: #ffffff; text-align: $toast-inner-text-align; line-height: 20px; - /* #ifdef harmony dynamic*/ - line-height: normal; - /* #endif */ - height: auto; + /* #ifdef harmony dynamic*/ + line-height: normal; + height: auto; + /* #endif */ }
111-114
: 与文本节点保持一致:为标题在 harmony 动态分支也加上 height:auto标题在 dynamic 下同样改为 line-height: normal,建议同步加 height:auto,避免在大字号/换行时潜在裁切,并与 &-text 保持一致。
请验证含标题+图标、标题多行场景在 harmony 端展示是否正常。
- /* #ifdef harmony dynamic*/ - line-height: normal; - /* #endif */ + /* #ifdef harmony dynamic*/ + line-height: normal; + height: auto; + /* #endif */src/packages/switch/switch.scss (1)
66-71
: 与根块保持一致的条件编译与布局检查(label 区域)
- 同样存在
/* #ifndef dynamic*/
少空格问题,建议统一。- 动态分支使用
display: flex
,在某些内联场景(文字内嵌开关、表单行内布局)可能导致换行或对齐差异。请在对应 Demo/用例中快速走查动态构建包的视觉与交互。最小修正:
- /* #ifndef dynamic*/ + /* #ifndef dynamic */可选:抽取一个 SCSS mixin 以减少重复(在公用样式中声明后复用):
@mixin display-dynamic($inline: true) { /* #ifndef dynamic */ @if $inline { display: inline-flex; } @else { display: flex; } /* #endif */ /* #ifdef dynamic */ display: flex; /* #endif */ } // 使用:@include display-dynamic($inline: true);src/hooks/taro/use-custom-event.ts (1)
6-6
: 建议移除已注释的旧代码。保留已注释的旧实现可能会造成代码库混乱。如果需要记录此变更,建议将其移至迁移文档或 git 提交记录中。
应用此 diff 移除注释:
-// export const customEvents = new Events() export const customEvents = eventCenter
src/packages/steps/steps.tsx (1)
42-42
: 建议缓存 children 个数以复用并提升可读性当前在类名与 “最后一项” 判断处重复调用 React.Children.count(children)。可提取为 childrenCount 复用,便于阅读并避免重复计算(微优化)。
可按如下调整:
- [`${classPrefix}-${direction}-count-${React.Children.count(children)}`]: true, + [`${classPrefix}-${direction}-count-${childrenCount}`]: true,- 'nut-step-last': index === React.Children.count(children) - 1, + 'nut-step-last': index === childrenCount - 1,在 classes 定义前新增一行:
const childrenCount = React.Children.count(children)Also applies to: 57-57
src/packages/button/button.taro.tsx (1)
5-8
: 清理注释代码。如果这些被注释的导入和类型定义不再需要,应该完全删除而不是保留为注释。保留注释代码会降低代码可读性和可维护性。
如果这是临时性的变更或正在进行的重构,建议在 PR 描述中说明原因和后续计划。
应用以下 diff 删除注释代码:
import classNames from 'classnames' import { - // ButtonProps as MiniProgramButtonProps, View, - // Button as TaroButton, } from '@tarojs/components' import { Loading } from '@nutui/icons-react-taro' import { BasicComponent, ComponentDefaults } from '@/utils/typings' import { harmony } from '@/utils/taro/platform' -// type OmitMiniProgramButtonProps = Omit< -// MiniProgramButtonProps, -// 'size' | 'type' | 'onClick' | 'style' -// >Also applies to: 13-16
src/packages/searchbar/searchbar.scss (1)
124-129
: 统一条件编译注释格式并回归验证构建输出
- 已确认仓库大量 SCSS 使用 /* #ifdef/#ifndef ... */(示例:src/packages/searchbar/searchbar.scss:124-129),且存在 dynamic 环境检测(src/utils/taro/platform.ts)与 Taro 相关构建依赖,表明构建链会处理条件编译分支。
- 问题:注释宏空格不一致(如
/* #ifndef dynamic*/
与/* #ifndef dynamic */
),建议统一为带空格形式以降低预处理器解析差异风险;若预处理未生效,后者的display: flex
会覆盖前者的display: inline-flex
,可能导致静默布局变更。- 建议:统一注释格式并在 H5/小程序(taro)目标上做视觉回归。
- /* #ifndef dynamic*/ + /* #ifndef dynamic */ display: inline-flex; - /* #endif */ - /* #ifdef dynamic*/ - display: flex; - /* #endif */ + /* #endif */ + /* #ifdef dynamic */ + display: flex; + /* #endif */src/packages/range/range.taro.tsx (1)
326-351
: 去掉多余的 async,避免无意义的 Promise
handleMove
未使用 await,声明为 async 没有意义,还可能带来未捕获异常。- const handleMove = async () => { + const handleMove = () => { if (!rootRect.current) return let delta = isHmsrc/packages/swipe/swipe.taro.tsx (1)
234-252
: 只在 H5 环境绑定 document 事件,避免小程序端报错小程序端无 document,此处建议按环境收敛。
- useEffect(() => { + useEffect(() => { + if (process.env.TARO_ENV !== 'h5') return // 并没有生效 const handler: any = (event: { target: Node | null }) => { const targets = [root] if ( targets.some((targetItem) => { const targetElement = targetItem.current || targetItem return !targetElement || targetElement?.contains(event.target) }) ) { return } close() } document.addEventListener('touchstart', handler) return () => { document.removeEventListener('touchstart', handler) } - }, [close]) + }, [close])src/packages/dialog/dialog.scss (1)
129-133
: Footer 按钮样式增强 OK;命名可读性建议
- 新增圆角与 padding 覆盖符合预期;取消按钮
border-color
回退透明安全。- 变量
$dialog-footer-button-border
实际用于 border-radius,命名与用途不符,建议后续统一为...BorderRadius
以提升可读性(保持旧名兼容一段时间)。Also applies to: 139-139, 147-150
src/packages/popup/popup.tsx (1)
69-70
: top 插槽定位需与 bottom 场景绑定并在尺寸变化时重算当前无论 position 为何都会渲染 top 容器,并仅在
innerVisible
变化时用clientHeight
设置bottom
。两点建议:
- 仅在
position === 'bottom' && top
时渲染/计算,避免 center/left/right 的不合理样式。- 在高度动态变化时重算(如 resizable 拖动、子内容变更)。可在
handleTouchMove
内同步更新,或将依赖改为[innerVisible, position, resizable, minHeight]
并在打开后requestAnimationFrame
再读尺寸。若需,我可给出补丁。
Also applies to: 92-92, 147-152, 192-200, 310-310
src/styles/variables-jrkf.scss (1)
129-129
: 新增公共变量完备且默认值合理
- 新增
$font-weight-medium
(500)、$dialog-title-margin-bottom
(8px)、$dialog-footer-button-border
(6px) 与本次样式改动匹配。- 可考虑将 “button-border” 变量名调整为 “button-border-radius” 提升语义清晰度(保留旧名别名做平滑迁移)。
Also applies to: 1617-1621, 1637-1641
src/styles/variables-jmapp.scss (1)
106-107
: JMApp 变量补齐一致与 JRKF 侧保持一致的
$font-weight-medium
、$dialog-title-margin-bottom
、$dialog-footer-button-border
,对齐良好。命名同样可考虑改为...BorderRadius
(保留兼容)。Also applies to: 1504-1507, 1524-1527
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (67)
package.json
(3 hunks)src/hooks/taro/use-custom-event.ts
(1 hunks)src/packages/animatingnumbers/countup.scss
(1 hunks)src/packages/avatarcropper/avatarcropper.taro.tsx
(3 hunks)src/packages/badge/badge.scss
(2 hunks)src/packages/button/button.scss
(1 hunks)src/packages/button/button.taro.tsx
(5 hunks)src/packages/cascader/cascader.scss
(1 hunks)src/packages/checkbox/checkbox.scss
(1 hunks)src/packages/checkbox/checkbox.taro.tsx
(1 hunks)src/packages/checkbox/checkbox.tsx
(1 hunks)src/packages/checkboxgroup/checkboxgroup.scss
(1 hunks)src/packages/configprovider/types.ts
(2 hunks)src/packages/dialog/demos/taro/demo6.tsx
(1 hunks)src/packages/dialog/dialog.scss
(3 hunks)src/packages/dialog/dialog.taro.tsx
(1 hunks)src/packages/divider/divider.scss
(1 hunks)src/packages/drag/drag.scss
(1 hunks)src/packages/elevator/elevator.scss
(2 hunks)src/packages/input/input.scss
(0 hunks)src/packages/input/input.taro.tsx
(2 hunks)src/packages/inputnumber/inputnumber.scss
(1 hunks)src/packages/loading/loading.scss
(1 hunks)src/packages/lottie/lottiemp.taro.tsx
(3 hunks)src/packages/menuitem/menuitem.scss
(1 hunks)src/packages/noticebar/demos/taro/demo10.tsx
(3 hunks)src/packages/noticebar/noticebar.scss
(1 hunks)src/packages/noticebar/noticebar.taro.tsx
(11 hunks)src/packages/notify/notify.scss
(1 hunks)src/packages/overlay/overlay.taro.tsx
(2 hunks)src/packages/popup/doc.en-US.md
(1 hunks)src/packages/popup/doc.md
(1 hunks)src/packages/popup/doc.taro.md
(1 hunks)src/packages/popup/popup.scss
(1 hunks)src/packages/popup/popup.taro.tsx
(8 hunks)src/packages/popup/popup.tsx
(5 hunks)src/packages/radio/radio.scss
(1 hunks)src/packages/range/range.taro.tsx
(2 hunks)src/packages/rate/rate.scss
(1 hunks)src/packages/rate/rate.taro.tsx
(3 hunks)src/packages/resultpage/resultpage.scss
(1 hunks)src/packages/searchbar/searchbar.scss
(1 hunks)src/packages/segmented/segmented.scss
(1 hunks)src/packages/sidebaritem/sidebaritem.scss
(1 hunks)src/packages/signature/demo.scss
(1 hunks)src/packages/skeleton/skeleton.scss
(1 hunks)src/packages/steps/steps.scss
(2 hunks)src/packages/steps/steps.taro.tsx
(1 hunks)src/packages/steps/steps.tsx
(1 hunks)src/packages/swipe/swipe.taro.tsx
(6 hunks)src/packages/switch/switch.scss
(2 hunks)src/packages/tabpane/tabpane.scss
(1 hunks)src/packages/tabs/tabs.scss
(1 hunks)src/packages/tag/tag.scss
(1 hunks)src/packages/timeselect/timeselect.scss
(1 hunks)src/packages/toast/toast.scss
(2 hunks)src/packages/virtuallist/virtuallist.scss
(1 hunks)src/sites/sites-react/doc/docs/react/migrate-from-v2.en-US.md
(1 hunks)src/sites/sites-react/doc/docs/react/migrate-from-v2.md
(1 hunks)src/sites/sites-react/doc/docs/taro/migrate-from-v2.en-US.md
(1 hunks)src/sites/sites-react/doc/docs/taro/migrate-from-v2.md
(1 hunks)src/styles/theme-default.scss
(2 hunks)src/styles/variables-jmapp.scss
(3 hunks)src/styles/variables-jrkf.scss
(3 hunks)src/styles/variables.scss
(9 hunks)src/types/spec/popup/base.ts
(1 hunks)src/utils/taro/get-rect-by-id.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- src/packages/input/input.scss
🧰 Additional context used
🧬 Code graph analysis (6)
src/packages/range/range.taro.tsx (1)
src/utils/taro/get-rect.ts (1)
getRectInMultiPlatform
(29-55)
src/packages/noticebar/noticebar.taro.tsx (2)
src/hooks/use-uuid.ts (1)
useUuid
(17-20)src/utils/taro/get-rect.ts (1)
getRectInMultiPlatform
(29-55)
src/packages/dialog/dialog.taro.tsx (2)
src/packages/dialog/content.taro.tsx (1)
Content
(16-75)src/packages/dialog/content.tsx (1)
Content
(15-74)
src/packages/button/button.taro.tsx (2)
src/packages/button/button.tsx (1)
ButtonProps
(18-32)src/utils/typings.ts (1)
BasicComponent
(3-8)
src/packages/popup/popup.taro.tsx (2)
src/utils/taro/get-rect.ts (1)
getRectInMultiPlatformWithoutCache
(58-76)src/utils/taro/px-transform.ts (1)
pxTransform
(5-9)
src/packages/swipe/swipe.taro.tsx (1)
src/utils/taro/get-rect.ts (1)
getRectInMultiPlatform
(29-55)
🪛 LanguageTool
src/sites/sites-react/doc/docs/taro/migrate-from-v2.en-US.md
[style] ~101-~101: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ht, which can be used with resizable. - Added a new attribute top to display user-def...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[grammar] ~101-~101: There might be a mistake here.
Context: ...ay user-defined content above the title. - Added the onTouchStart, onTouchMove, and...
(QB_NEW_EN)
src/sites/sites-react/doc/docs/react/migrate-from-v2.en-US.md
[style] ~101-~101: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ht, which can be used with resizable. - Added a new attribute top to display user-def...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[grammar] ~101-~101: There might be a mistake here.
Context: ...ay user-defined content above the title. - Added the onTouchStart, onTouchMove, and...
(QB_NEW_EN)
🔇 Additional comments (62)
src/packages/steps/steps.taro.tsx (1)
41-46
: 本次改动仅为格式化,行为未变更,LGTM。src/packages/virtuallist/virtuallist.scss (2)
37-41
: 确认 .nut-virtualList-box 选择器已生效
根据搜索,.nut-virtualList-box 已在 src/packages/virtuallist/virtuallist.tsx、virtuallist.taro.tsx、demo.tsx 及测试文件中使用,无需修改命名风格。
37-41
: 验证生产构建是否保留 SCSS 条件注释
当前通过/* #ifndef dynamic */…/* #endif */
控制动态模式样式注入,请确认 Sass 编译及 PostCSS(尤其是 cssnano/discard-comments 等压缩插件)流程不会剥离该注释,否则动态模式样式过滤将失效。src/packages/tabpane/tabpane.scss (1)
9-11
: 校验 conditional compilation 生效与注释格式一致,测试 dynamic 模式下滚动行为
- 构建链支持:确认 Taro/预处理器正确剔除
/* #ifndef dynamic */ … /* #endif */
块,dynamic 宏已注入。- 统一注释:将所有
/* #ifndef dynamic*/
和/* #ifdef dynamic */
规范为/* #ifndef dynamic */
//* #ifdef dynamic */
。- 滚动验证:在 H5 与各小程序端用长内容 Tab 实测 dynamic 模式下是否出现内容溢出或无法滚动。
src/packages/switch/switch.scss (1)
4-9
: 统一修复dynamic
条件注释空格格式并确认构建预处理
- 多处存在
/* #ifndef dynamic*/
(缺少空格),建议批量替换为/* #ifndef dynamic */
,可用:rg -l '/\*\s*#ifn?def\s+dynamic\*/' -g '!**/dist/**' | xargs sed -E -i 's|/\*\s*#(ifn?def) dynamic\*/|/* #\1 dynamic */|g'- 请确认构建管道已集成对
/* #ifdef/#ifndef dynamic */
注释的条件编译处理,否则最终产物中会同时保留两条display
规则,造成样式覆盖问题。src/packages/sidebaritem/sidebaritem.scss (1)
10-12
: 验证动态编译条件和滚动容器支持
- 请确认构建链是否识别并移除 SCSS 中的 /* #ifndef dynamic /…/ #endif */ 注释,否则 overflow: auto 的移除不会生效或会引发不确定行为
- 确认 dynamic 模式下 .nut-sidebaritem 是否处于可滚动的父容器内,否则长期内容将失去滚动能力
- 建议将
.inactive
的overflow: visible
改为hidden
以收敛溢出,示例:.nut-sidebaritem { … /* #ifndef dynamic */ overflow: auto; /* #endif */ … &.inactive { - overflow: visible; + overflow: hidden; height: 0; } }src/hooks/taro/use-custom-event.ts (1)
3-7
: 验证全局 eventCenter 共享事件总线的风险
- 确认 useCustomEventsPath 生成的事件路径在所有页面和组件实例中唯一,避免不同场景下命名冲突
- 删除顶部无用注释:
// export const customEvents = new Events()
src/packages/animatingnumbers/countup.scss (1)
3-8
: 使用 dynamic 条件编译切换 display,请确认构建链与布局影响
- 构建验证:确认已在 SCSS 构建链(Webpack/Vite/Taro)中启用条件编译并定义
dynamic
宏,否则会同时输出display: inline-flex
和display: flex
,最终以flex
生效,可能改变 H5 布局。- 布局核对:
inline-flex → flex
会由行内级变为块级,可能影响文字同行对齐或产生换行,建议在对应环境下验证 CountUp 与文本的渲染效果。可选优化:
- 统一注释风格(
/* #ifndef dynamic */
//* #endif */
),便于检索。- 抽成 mixin 或占位选择器,减少重复。
src/packages/input/input.taro.tsx (2)
10-10
: 环境类型常量使用不一致 & disabled/readOnly 行为拆分
代码中既使用本地 ENV_TYPE.WEB ,又直接比较字符串 'WEB',建议:
• 如果 Taro 4.0.12 导出 ENV_TYPE,则从 @tarojs/taro 恢复导入并删除本地定义;
• 否则全局统一用字符串字面量并移除本地 ENV_TYPE 。
请确认 Taro 实际导出情况。将
disabled || readOnly
改为仅disabled
后,readOnly
不再隐式禁用交互,需评估此行为变更是否符合预期并兼容现有用例。
211-211
: 确认 Input Taro 组件的 readOnly 行为
- 当前已将 disabled 与 readOnly 分离:disabled 仅控制禁用,readOnly 单独传递给原生输入,并在清除按钮(
clearable && !readOnly
)中正确排除。- 请在各端手动验证 TaroInput 对 readOnly 的原生支持(聚焦、光标与键盘交互)是否符合预期。
src/packages/button/button.taro.tsx (1)
80-80
: Also applies to: 149-151package.json (1)
3-3
: 版本号提升为预发布标记(cpp.10)请同步发布资产请同步更新 CHANGELOG、打 tag(含预发布 tag)、并确认 npm dist-tags(如 beta/canary)策略一致,避免安装到非预期版本。
src/types/spec/popup/base.ts (1)
20-20
: LGTM!新增的
top
属性与现有的left
和title
属性保持一致的可选类型定义,实现合理。src/packages/tag/tag.scss (1)
65-70
: 动态构建模式支持已正确实现。使用条件编译指令根据
dynamic
标志切换display
属性(inline-flex
vsflex
)的方式与项目中其他组件的实现模式一致。src/packages/notify/notify.scss (1)
78-83
: LGTM!图标容器的动态模式显示属性切换实现与其他组件保持一致。
src/packages/avatarcropper/avatarcropper.taro.tsx (2)
8-8
: 正确引入 Taro 生命周期钩子。从
@tarojs/taro
引入useReady
用于替代 React 的useLayoutEffect
,这是 Taro 小程序环境的最佳实践。
140-152
: 使用useReady
替代useLayoutEffect
符合 Taro 规范。在 Taro 环境中,
useReady
是正确的页面就绪生命周期钩子。移除依赖数组也是正确的,因为useReady
不接受依赖项参数。src/utils/taro/get-rect-by-id.ts (2)
18-18
: 环境检查已更新为使用本地常量。将 WEB 环境检查从
Taro.ENV_TYPE.WEB
改为ENV_TYPE.WEB
。假设这是为了解决 PR 标题中提到的边界矩形问题,请确保此更改已充分测试。
3-14
: 确认 Taro.ENV_TYPE 可用性或移除冗余常量。本地新增的
ENV_TYPE
与Taro.ENV_TYPE
定义重复,请:
- 确认
import Taro from '@tarojs/taro'
后Taro.ENV_TYPE
在当前版本中是否可用且类型符合预期;- 如可用,直接使用内置常量并删除本地重复定义;
- 如存在兼容性或类型差异,请在代码中注明原因并标注受影响的 Taro 版本。
src/packages/resultpage/resultpage.scss (1)
9-14
: LGTM!结果页图标的动态模式显示属性实现与其他组件保持一致。
src/packages/tabs/tabs.scss (2)
113-115
: LGTM!活跃标签下划线的
overflow: unset
仅在非动态模式下应用,这与组件的视觉效果需求一致。
123-125
: LGTM!活跃标签笑脸图标的
overflow: unset
条件应用与下划线样式保持一致。src/packages/drag/drag.scss (1)
10-15
: LGTM!拖拽组件内部元素的动态模式显示属性切换实现正确。
src/packages/inputnumber/inputnumber.scss (1)
2-11
: 条件编译块遵循 PR 的一致模式。此文件应用了与其他组件相同的条件
display
属性切换逻辑。width 计算的换行是格式调整,不影响功能。请参考
radio.scss
中的审查意见,确保构建工具链支持这些指令。src/packages/loading/loading.scss (1)
2-7
: LGTM - 遵循一致的条件编译模式。Loading 组件采用了与其他组件相同的条件
display
切换策略。确保在动态模式下,加载指示器的布局和对齐方式符合预期。src/packages/checkboxgroup/checkboxgroup.scss (1)
33-38
: LGTM - 横向复选框组中的条件显示。此更改将条件编译应用于横向布局中的复选框,保持了 PR 的一致模式。
src/packages/signature/demo.scss (1)
16-21
: LGTM - 演示文件中的条件显示。演示按钮也应用了条件编译模式,确保演示代码与实际组件保持一致的行为。
src/packages/steps/steps.scss (2)
117-122
: LGTM - 步骤线内部元素的条件显示。横向双列步骤条的内部线元素应用了条件编译模式,与其他组件保持一致。
240-242
: 验证移除溢出滚动对纵向标题的影响。在动态模式下移除了
overflow: auto
。请确认:
- 当标题文本过长时,在动态模式下如何处理?
- 是否会导致文本溢出或布局问题?
- 是否有其他机制来处理长文本?
建议进行视觉回归测试,验证长标题在动态模式下的表现。
src/packages/overlay/overlay.taro.tsx (2)
71-85
: 确认 Taro 版 Overlay 移除动画为有意一致性变更 与 popup.taro.tsx、dialog.taro.tsx 保持统一,afterShow
/afterClose
为内部回调且未被其他模块引用,无需额外处理。
62-62
: 无需调整:overlay.scss 中未定义 display 属性,无冲突风险
inline display 不会覆盖任何现有样式。src/packages/badge/badge.scss (1)
3-8
: 验证 display: inline-flex ↔ flex 切换对徽章定位和对齐的影响
徽章在两处应用了条件显示切换
- 根元素
.nut-badge
- 上标变体
&-sup
可能影响徽章相对于父元素的定位及与内联元素对齐,建议在核心页面布局和所有使用场景中进行视觉回归验证。src/packages/range/range.taro.tsx (1)
289-299
: useReady + nextTick 的测量时机调整方向正确从 useLayoutEffect 迁移到 useReady/nextTick 获取 rect 更符合小程序生命周期,LGTM。
src/packages/lottie/lottiemp.taro.tsx (2)
23-28
: setSpeed 逻辑清晰速度与方向分离设置,简洁可读,LGTM。
31-31
: 初始化迁移到 useReady 合理初始化放到 onReady 后执行,配合 selectorQuery 更稳妥,LGTM。
Also applies to: 75-75
src/styles/variables.scss (1)
155-157
: 样式 Token 调整方向一致且可控
- 字号体系 L=15px、新增 icon 字号 OK
- 新增 500 字重 OK
- Dialog/Popup/Input/Checkbox/Radio 等默认值对齐新版 Token OK
变更面向样式,不引入运行时风险,LGTM。
Also applies to: 165-166, 598-599, 1084-1085, 1397-1402, 1414-1417, 1428-1429, 1435-1437, 1476-1478, 1516-1519
src/styles/theme-default.scss (1)
262-264
: 主题 Token 更新与变量表一致字号与字重 Token 同步,LGTM。
Also applies to: 276-278
src/sites/sites-react/doc/docs/react/migrate-from-v2.en-US.md (1)
101-101
: 文档更新正确。新增的
top
属性文档描述准确,用于在标题上方显示用户自定义内容。src/sites/sites-react/doc/docs/react/migrate-from-v2.md (1)
101-101
: 文档更新正确。新增的
top
属性文档描述准确,符合语言规范。src/sites/sites-react/doc/docs/taro/migrate-from-v2.md (1)
101-101
: 文档更新正确。新增的
top
属性文档描述准确。src/packages/popup/doc.en-US.md (1)
94-94
: 文档更新正确。新增的
top
属性文档条目格式正确,描述清晰。src/packages/checkbox/checkbox.taro.tsx (1)
201-201
: 代码更改正确。添加了基于选中状态的 CSS 类绑定,用于样式控制。实现简洁且不影响现有逻辑。
src/packages/checkbox/checkbox.tsx (1)
206-206
: 代码更改正确。添加了基于选中状态的 CSS 类绑定,与 Taro 版本保持一致。实现简洁且符合预期。
src/sites/sites-react/doc/docs/taro/migrate-from-v2.en-US.md (1)
101-101
: 文档更新正确。新增的
top
属性文档描述准确,与其他英文文档保持一致。src/packages/popup/doc.md (1)
94-94
: 文档更新正确。新增的
top
属性文档条目格式正确,类型和默认值符合规范。src/packages/noticebar/demos/taro/demo10.tsx (1)
6-9
: 示例代码改进合理。通过增加更长的文本内容、设置
scrollable={false}
以及添加文本截断样式,清楚地演示了 NoticeBar 组件的文本溢出处理能力。Also applies to: 20-20, 31-37
src/packages/popup/popup.scss (1)
102-104
: 验证样式定义的完整性。新增的
.nut-popup-bottom-top
选择器仅设置了position: absolute
,但缺少其他定位属性(如top
、left
、width
等)。请确认这是否足以满足顶部插槽的布局需求,或者是否需要在组件内部通过内联样式补充。src/packages/checkbox/checkbox.scss (1)
68-73
: 动态编译块使用正确。通过条件编译切换
display
属性(inline-flex
与flex
),与 PR 中其他组件(badge、noticebar、loading 等)的模式保持一致。src/packages/dialog/demos/taro/demo6.tsx (1)
43-46
: 回调函数添加合理。新增的
onClose
回调展示了关闭按钮的处理逻辑。虽然与onConfirm
和onCancel
存在功能重叠(都调用setVisible2(false)
),但这在演示代码中是合理的,有助于展示不同回调的触发时机。src/packages/noticebar/noticebar.scss (1)
39-47
: 动态编译块使用正确。通过条件编译控制
flex
和display
属性,仅在非动态模式下应用,与其他组件的实现模式一致。src/packages/rate/rate.taro.tsx (1)
10-10
: 从 React 生命周期迁移到 Taro 生命周期。将
useLayoutEffect
+useCallback
替换为useReady
是正确的 Taro 平台适配。但需要注意行为变化:
- 之前:
useLayoutEffect
会在 refs 变化时重新执行updateRects
- 现在:
useReady
仅在组件准备完成时执行一次虽然
handleTouchStart
中仍会调用updateRects
,但如果 refs 在初始化后动态变化(如条件渲染、列表更新),可能需要额外的更新机制。请确认在count
变化导致 refs 数量改变时,布局计算是否仍然准确。Also applies to: 134-147
src/packages/dialog/dialog.scss (3)
22-27
: 按需包围 transition 的条件编译处理合理将过渡属性置于 dynamic 之外可避免不支持过渡的平台异常,变更可取。
88-90
: 标题与内容间距 token 化良好新增
$dialog-title-margin-bottom
使用恰当,利于主题扩展。
11-14
: 确认条件编译指令语法兼容性
请核实构建/预处理流程是否支持/* #ifndef harmony dynamic*/
多标识并列;如不支持,拆分为嵌套或单独条件指令(/* #ifndef harmony*/…/*#endif*/
或/* #ifndef dynamic*/…/*#endif*/
)。src/packages/rate/rate.scss (1)
100-106
: 动态构建下的 display 分支切换 OK;请确认一致性
inline-flex
与flex
的切换符合其它组件的 dynamic 约定。请确认所有动态主题下.nut-rate-score
的父级布局没有依赖 inline 级流,否则需同步调整间距。src/packages/configprovider/types.ts (1)
59-60
: Type 覆盖到位已为新增变量补齐
NutCSSVariables
联合类型:icon 字号、中等字重、Dialog 间距与按钮圆角,类型面向外部消费完整。Also applies to: 66-67, 464-470
src/packages/noticebar/noticebar.taro.tsx (1)
73-76
: 基于唯一 id 的跨端测量改造合理引入
useUuid
并在 Taro 端通过 id 选择器参与测量,命中多端getRectInMultiPlatform
逻辑,改造方向正确。请确认其它依赖测量的组件也统一采用 id 方式,避免 element.uid 在部分端不可用的潜在问题。
Also applies to: 505-510, 164-168
src/packages/popup/popup.taro.tsx (5)
9-9
: 导入看起来正确。引入
nextTick
用于在 Taro 多平台环境中调度高度计算是合适的做法。
103-103
: 新增的 ref 和 state 看起来合理。
topNodeRef
和topBottom
的添加为支持顶部插槽功能提供了必要的状态管理。Also applies to: 126-126
211-222
: renderTop 实现清晰,定位逻辑待验证。函数结构良好,逻辑清晰。
bottom: topBottom
的定位方式将顶部元素从其父容器底部向上偏移。请确保配合相应的 CSS 样式(如绝对定位),这种定位方式能实现预期的布局效果。
156-160
: 未能在代码库中找到 “popup-bottom-top” 或相关定位样式,请确认顶部元素是否已绝对定位(或固定定位)脱离文档流,以及topBottom
值如何应用,以避免弹窗高度与顶部元素定位之间的循环依赖。
73-73
: 无需修改:top
属性已在BasePopup
(TaroPopupProps 继承)中声明,类型为 ReactNode。
"@nutui/icons-react-taro": "^3.0.2-cpp.2", | ||
"@nutui/jdesign-icons-react-taro": "1.0.6-beta.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
pnpm 下 “resolutions” 不生效且版本不一致,建议改为 overrides 并对齐版本
- 当前依赖为 @nutui/icons-react-taro: ^3.0.2-cpp.2,但 resolutions 中为 ^3.0.2-cpp.1;存在不一致,且在 pnpm 下 resolutions 通常不会生效,可能导致实际解析版本不可控。
- 建议将 “resolutions” 更名为顶层 “overrides”(pnpm/npm 均支持),并将 @nutui/icons-react-taro 固定为 3.0.2-cpp.2 以与 dependencies 对齐。
建议修改如下:
- "resolutions": {
+ "overrides": {
"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19",
"sass": "1.77.6",
"@tarojs/api": "4.0.12",
"@tarojs/components": "4.0.12",
- "@nutui/icons-react-taro": "^3.0.2-cpp.1"
+ "@nutui/icons-react-taro": "3.0.2-cpp.2"
}
说明:
- 若团队仍需兼容 Yarn,可保留 “resolutions”,但在 pnpm 场景下仍需 “overrides” 才能保证一致解析。
为确认当前仓库实际使用的包管理器与已解析版本,可运行:
Also applies to: 245-246, 239-246
🏁 Script executed:
#!/bin/bash
# 检查锁文件与包管理器线索
fd -a 'pnpm-lock.yaml' -H || true
fd -a 'yarn.lock' -H || true
jq -r '.packageManager // empty' package.json 2>/dev/null || true
# 检查 lock 中解析到的 @nutui/icons-react-taro 版本(pnpm 或 yarn)
rg -nC1 '@nutui/icons-react-taro' pnpm-lock.yaml yarn.lock 2>/dev/null || true
Length of output: 905
使用 overrides 替换 resolutions 并对齐 @nutui/icons-react-taro 版本
- pnpm 不识别 package.json 中的 "resolutions",需改为顶层 "overrides"
- 将 "@nutui/icons-react-taro" 固定为 "3.0.2-cpp.2" 以匹配 dependencies
- "resolutions": {
+ "overrides": {
"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19",
"sass": "1.77.6",
"@tarojs/api": "4.0.12",
"@tarojs/components": "4.0.12",
- "@nutui/icons-react-taro": "^3.0.2-cpp.1"
+ "@nutui/icons-react-taro": "3.0.2-cpp.2"
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"@nutui/icons-react-taro": "^3.0.2-cpp.2", | |
"@nutui/jdesign-icons-react-taro": "1.0.6-beta.2", | |
"overrides": { | |
"@types/react": "^18.2.57", | |
"@types/react-dom": "^18.2.19", | |
"sass": "1.77.6", | |
"@tarojs/api": "4.0.12", | |
"@tarojs/components": "4.0.12", | |
"@nutui/icons-react-taro": "3.0.2-cpp.2" | |
} |
🤖 Prompt for AI Agents
In package.json around lines 112-113, replace any top-level "resolutions" entry
with a top-level "overrides" object and set "@nutui/icons-react-taro" to the
exact version "3.0.2-cpp.2" (remove the caret) so it matches the dependencies;
update the dependency entry to that exact version, add an "overrides": {
"@nutui/icons-react-taro": "3.0.2-cpp.2" } at the package.json root if not
present, remove the old "resolutions" block, and then run pnpm install to
regenerate the lockfile.
/* #ifdef dynamic*/ | ||
pointer-events: none; | ||
/* #endif */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
功能修复合理,但请确认条件宏一致性(dynamic vs harmony dynamic)
此处给 ::before 加 pointer-events: none 能避免覆盖层拦截点击,方向正确。不过本文件前面使用的是 “/* #ifdef harmony dynamic*/”,这里写成了 “/* #ifdef dynamic*/”。若两者在构建预处理并非同义,可能导致某些端未生效,仍出现点击被遮挡的问题。建议统一为同一宏,或两者都兼容一遍以免漏网。
为便捷核查,可在仓库根目录运行下列脚本统计两种写法的分布,评估是否需要统一:
🏁 Script executed:
#!/bin/bash
# 检查 SCSS 中 dynamic 条件宏的用法是否一致
echo "Match: /* #ifdef dynamic*/"
rg -n -C1 -g '**/*.scss' $'/\\*\\s*#ifdef\\s+dynamic\\s*\\*/'
echo
echo "Match: /* #ifdef harmony dynamic*/"
rg -n -C1 -g '**/*.scss' $'/\\*\\s*#ifdef\\s+harmony\\s+dynamic\\s*\\*/'
echo
echo "本文件定位:"
rg -n -C2 -g 'src/packages/button/button.scss' $'/\\*\\s*#if(n)?def\\b[^*]*\\*/|pointer-events\\s*:\\s*none\\s*;'
Length of output: 8219
🏁 Script executed:
#!/bin/bash
echo "Context around ::before in src/packages/button/button.scss"
rg -n -C5 '::before' -g 'src/packages/button/button.scss'
echo
echo "Full file beginning (lines 1–200):"
sed -n '1,200p' src/packages/button/button.scss
Length of output: 6348
保持条件宏一致 将 pointer-events
区块的宏由
/* #ifdef dynamic*/
pointer-events: none;
/* #endif */
改为
/* #ifdef harmony dynamic*/
pointer-events: none;
/* #endif */
确保与文件其他处使用的宏一致,否则该样式在部分构建条件下无法生效。
🤖 Prompt for AI Agents
In src/packages/button/button.scss around lines 58 to 60, the conditional macro
around the pointer-events block is inconsistent with the project's convention;
update the opening macro from "/* #ifdef dynamic*/" to "/* #ifdef harmony
dynamic*/" so the block matches other uses of the harmony macro and will be
included under the correct build conditions; keep the closing "/* #endif */"
as-is.
// <CSSTransition | ||
// in={visible} | ||
// timeout={300} | ||
// classNames="fadeDialog" | ||
// unmountOnExit | ||
// appear | ||
// > | ||
<Content | ||
className={className} | ||
style={{ | ||
zIndex: contentZIndex, | ||
...style, | ||
display: visible ? 'block' : 'none', | ||
}} | ||
title={title} | ||
header={header} | ||
close={renderCloseIcon()} | ||
footer={renderFooter()} | ||
footerDirection={footerDirection} | ||
visible={visible} | ||
> | ||
<Content | ||
className={className} | ||
style={{ zIndex: contentZIndex, ...style }} | ||
title={title} | ||
header={header} | ||
close={renderCloseIcon()} | ||
footer={renderFooter()} | ||
footerDirection={footerDirection} | ||
visible={visible} | ||
> | ||
{content || children} | ||
</Content> | ||
</CSSTransition> | ||
{content || children} | ||
</Content> | ||
// </CSSTransition> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
移除过渡动画影响用户体验。
移除 CSSTransition
包装器导致对话框的显示/隐藏变为瞬时切换,失去了原有的淡入淡出动画效果。这是一个较大的行为变更,可能影响用户体验。
请确认:
- 此变更是否为有意为之(例如 Taro 平台兼容性要求)?
- 是否已在迁移文档中说明此行为变化?
- 是否考虑过通过其他方式(如 CSS 动画)恢复过渡效果?
运行以下脚本验证其他 Taro 组件是否有类似的 CSSTransition 移除:
🏁 Script executed:
#!/bin/bash
# 搜索 Taro 组件中是否还有使用 CSSTransition 的情况
rg -nP --type=tsx -C3 'CSSTransition' -g '*.taro.tsx'
Length of output: 27
重新运行以下脚本验证其他 Taro 组件中是否仍使用 CSSTransition:
🏁 Script executed:
#!/bin/bash
rg -n 'CSSTransition' -C3 -g '*.taro.tsx'
Length of output: 5872
补充迁移文档:Taro 版组件已移除 CSSTransition 动画
所有 Taro 平台组件(dialog、overlay、popup、notify、menuitem)已统一注释/移除 CSSTransition
,为兼容小程序环境导致的行为变更,请在迁移指南中说明:
- 明确告知原有淡入淡出或滑动动画已被移除
- 如需过渡效果,可在项目中通过 CSS 动画或关键帧自行实现并示例说明
🤖 Prompt for AI Agents
In src/packages/dialog/dialog.taro.tsx around lines 215 to 238, the
CSSTransition animation wrapper has been removed/ commented out for Taro builds
which changes visual behavior; update the project migration guide to state
clearly that Taro components (dialog, overlay, popup, notify, menuitem) no
longer include CSSTransition-based enter/exit animations, note that fade/slide
transitions have been removed, and provide instructions and a minimal example
showing how consumers can re-add transitions using CSS animations or keyframes
(include example selectors, keyframe names, and where to place the styles or
import them in Taro projects); also add a short compatibility note on
small-program behavior and recommend testing on target mini-program platforms.
.nut-icon { | ||
/* #ifndef dynamic*/ | ||
display: inline-flex; | ||
/* #endif */ | ||
/* #ifdef dynamic*/ | ||
display: flex; | ||
/* #endif */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
条件编译块整体合理,但请确认样式侧已开启条件编译;建议调整顺序以更安全降级
-
在 flex 子项中,inline-flex 与 flex 的外部表现等价,此改动风险低,OK。
-
风险提示:若构建链未剔除
/* #if... */
注释,两个 display 会同时下发,后者display: flex
将覆盖默认的inline-flex
,导致非 dynamic 构建与预期不符。请确认样式(SCSS/PostCSS)阶段的条件编译已启用并识别dynamic
。 -
小优化建议:对调两个条件块顺序,让非 dynamic 的
inline-flex
落在后面,即使条件编译失效也更贴近默认期望。
- /* #ifndef dynamic*/
- display: inline-flex;
- /* #endif */
- /* #ifdef dynamic*/
- display: flex;
- /* #endif */
+ /* #ifdef dynamic*/
+ display: flex;
+ /* #endif */
+ /* #ifndef dynamic*/
+ display: inline-flex;
+ /* #endif */
🏁 Script executed:
#!/bin/bash
# 1) 检查仓库中 dynamic 条件编译用法(样式/源码)
rg -n -C1 -S -g '!**/dist/**' -P '#ifn?def\s+dynamic|#endif' --type-add 'style:*.scss' --type style
# 2) 发现 Taro/构建配置与插件线索(是否对样式做条件编译)
fd -H 'taro*.config.*' -t f
rg -n -C1 -S -g 'config/**' 'conditional|ifdef|ifndef|dynamicCompile|taro-plugin' || true
# 3) 粗查已编译产物中是否仍残留 #ifdef(若有则说明未被处理)
rg -n -S -g '**/*.{css,scss}' '#ifdef|#ifndef|#endif' || true
Length of output: 32382
🏁 Script executed:
#!/bin/bash
# 查找 postcss 配置文件
fd -H 'postcss.config.js' -t f
# 输出前 200 行内容(如果存在)
if [ -f postcss.config.js ]; then
sed -n '1,200p' postcss.config.js
fi
# 在 package.json 中查找条件编译插件或关键字
rg -n 'postcss-plugin-ifdef' -g 'package.json'
rg -n 'ifdef' -g 'package.json'
rg -n 'postcss' -g 'package.json'
Length of output: 468
添加或确认 SCSS 条件编译插件设置
- 在 package.json 与构建配置中未发现任何可处理
/* #ifdef dynamic */
注释的插件,若注释未被剔除,最终产物中会同时包含display: inline-flex;
与display: flex;
,且后者覆盖前者,导致动态开关失效。 - 需在构建链(PostCSS/SCSS)中引入条件编译插件(如 postcss-plugin-ifdef)或通过其他方案移除相关注释,确保
dynamic
标记生效。 - 可选:将
inline-flex
块置于后面,即使插件失效也能降级为预期样式。
🤖 Prompt for AI Agents
In src/packages/menuitem/menuitem.scss around lines 31-37 the conditional SCSS
markers (/* #ifdef dynamic */ / /* #ifndef dynamic */) are not being processed
by the build, so both display rules may end up in the final CSS and break the
dynamic toggle; fix by adding and configuring a conditional compilation plugin
in the build (e.g., install and configure postcss-plugin-ifdef in package.json
and the PostCSS or SCSS pipeline so the /* #ifdef dynamic */ blocks are
removed/kept based on the dynamic flag), or alternatively remove these comment
guards and implement the dynamic behavior in CSS/JS, or as a quick fallback swap
the order so display: inline-flex; comes after display: flex; to preserve the
intended inline-flex when the plugin is absent.
| minHeight | 设置最小高度 | `string` | `26%` | | ||
| left | 标题左侧部分 | `ReactNode` | `-` | | ||
| title | 标题中间部分 | `ReactNode` | `-` | | ||
| top | 頂部佔位 | `ReactNode` | `-` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
语言一致性问题。
文档使用了繁体中文"頂部佔位",而项目其他中文文档使用简体中文。为保持一致性,建议修改为简体中文。
-| top | 頂部佔位 | `ReactNode` | `-` |
+| top | 顶部占位 | `ReactNode` | `-` |
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| top | 頂部佔位 | `ReactNode` | `-` | | |
| top | 顶部占位 | `ReactNode` | `-` | |
🤖 Prompt for AI Agents
In src/packages/popup/doc.taro.md around line 104, the entry uses Traditional
Chinese "頂部佔位" which is inconsistent with the project's Simplified Chinese docs;
change that phrase to the Simplified Chinese equivalent "顶部占位" so the language
matches other documentation.
// const renderPop = () => { | ||
// return ( | ||
// <CSSTransition | ||
// nodeRef={nodeRef} | ||
// classNames={transitionName} | ||
// mountOnEnter | ||
// unmountOnExit={destroyOnClose} | ||
// timeout={duration} | ||
// in={innerVisible} | ||
// onEntered={afterShow} | ||
// onExited={afterClose} | ||
// > | ||
// {renderContent()} | ||
// </CSSTransition> | ||
// ) | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
移除已注释的代码块。
这段大型的注释代码块降低了可读性和可维护性。如果需要保留旧实现作为参考,应该依赖版本控制历史而不是注释代码。
应用此差异移除注释的代码:
- // const renderPop = () => {
- // return (
- // <CSSTransition
- // nodeRef={nodeRef}
- // classNames={transitionName}
- // mountOnEnter
- // unmountOnExit={destroyOnClose}
- // timeout={duration}
- // in={innerVisible}
- // onEntered={afterShow}
- // onExited={afterClose}
- // >
- // {renderContent()}
- // </CSSTransition>
- // )
- // }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// const renderPop = () => { | |
// return ( | |
// <CSSTransition | |
// nodeRef={nodeRef} | |
// classNames={transitionName} | |
// mountOnEnter | |
// unmountOnExit={destroyOnClose} | |
// timeout={duration} | |
// in={innerVisible} | |
// onEntered={afterShow} | |
// onExited={afterClose} | |
// > | |
// {renderContent()} | |
// </CSSTransition> | |
// ) | |
// } |
🤖 Prompt for AI Agents
In src/packages/popup/popup.taro.tsx around lines 356 to 371, remove the large
commented-out renderPop CSSTransition block entirely (delete those commented
lines) to improve readability and rely on git history for the previous
implementation; after removal, run the project's linter/formatter and ensure no
leftover trailing whitespace or unused imports remain, then commit the change
with a brief message like "chore: remove commented legacy renderPop block".
/* #ifndef dynamic*/ | ||
display: inline-flex; | ||
/* #endif */ | ||
/* #ifdef dynamic*/ | ||
display: flex; | ||
/* #endif */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
验证条件编译指令的构建工具支持。
这些 /* #ifndef dynamic */
和 /* #ifdef dynamic */
指令看起来像是条件编译语法,但需要确认:
- 构建工具链是否支持这种 SCSS/CSS 预处理指令?
dynamic
标志在哪里定义和配置?- 从
inline-flex
切换到flex
对单选按钮布局的影响是什么?
请运行以下脚本验证条件编译配置:
🏁 Script executed:
#!/bin/bash
# 搜索 dynamic 标志的定义和配置
rg -n "dynamic" --type-add 'config:*.{json,js,ts,config.*}' -tconfig -C3
# 搜索类似的条件编译指令使用
rg -n "#ifndef|#ifdef|#endif" --type=scss -C2
Length of output: 6004
确认构建管道对注释指令的处理或改用 Sass 条件语法
- 验证是否有插件剔除
/* #ifdef dynamic */
//* #ifndef dynamic */
注释,否则编译后两条 display 都会生效,最终始终为 flex - 或改为使用 Sass 标准
@if $dynamic { ... }
并在 SCSS 层面定义$dynamic
变量
🤖 Prompt for AI Agents
In src/packages/radio/radio.scss around lines 52 to 57, the CSS uses
comment-based conditional markers (/* #ifndef dynamic */ / /* #ifdef dynamic */)
which may not be removed by the build pipeline causing both display rules to
apply; either ensure the build pipeline/plugin strips those comment directives
before CSS is emitted or replace them with Sass conditional syntax: define a
$dynamic variable at the SCSS level and use @if $dynamic { display: flex } @else
{ display: inline-flex } so only one display rule is present after compilation.
const getWidth = async () => { | ||
if (leftWrapper.current) { | ||
const leftRect = await getRectInMultiPlatform(leftWrapper.current, leftId) | ||
leftRect && setActionWidth((v: any) => ({ ...v, left: leftRect.width })) | ||
} | ||
if (rightWrapper.current) { | ||
const rightRect = await getRectInMultiPlatform( | ||
rightWrapper.current, | ||
rightId | ||
) | ||
rightRect && | ||
setActionWidth((v: any) => ({ ...v, right: rightRect.width })) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setActionWidth 实现有误,可能直接抛 TypeError
- setActionWidth 调用
fn()
未传入 prev,fn 内又使用{ ...v }
,v 为 undefined 会抛错。 - 简化为“基于当前值合并更新”的实现更稳妥。
- const setActionWidth = (fn: any) => {
- const res = fn()
- if (res.left !== undefined) {
- updateState({
- ...actionWidth.current,
- left: res.left,
- })
- }
- if (res.right !== undefined) {
- updateState({
- ...actionWidth.current,
- right: res.right,
- })
- }
- }
+ const setActionWidth = (
+ updater: (prev: { left: number; right: number }) => Partial<{ left: number; right: number }>
+ ) => {
+ const next = updater(actionWidth.current)
+ updateState({ ...actionWidth.current, ...next })
+ }
并据此修改调用处:
- leftRect && setActionWidth((v: any) => ({ ...v, left: leftRect.width }))
+ leftRect && setActionWidth(() => ({ left: leftRect.width }))
...
- rightRect && setActionWidth((v: any) => ({ ...v, right: rightRect.width }))
+ rightRect && setActionWidth(() => ({ right: rightRect.width }))
Also applies to: 84-99
🤖 Prompt for AI Agents
In src/packages/swipe/swipe.taro.tsx around lines 49 to 63 (also apply same
pattern to 84-99), the setActionWidth functional updater assumes the previous
state parameter exists and spreads v directly which can be undefined and throw a
TypeError; change each setActionWidth call to use the functional form that
accepts prev and merges safely, e.g. use prev => ({ ...(prev || {}), left:
<value> }) or prev => ({ ...(prev || {}), right: <value> }) so we never spread
undefined and always merge against the current state.
lockClick.current = true | ||
const newState = { ...state, dragging: true } | ||
const isEdge = !opened || touch.deltaX.current * startOffset.current < 0 | ||
if (isEdge) { | ||
preventDefault(event, true) | ||
} | ||
|
||
newState.offset = rangeCalculation( | ||
const offset = rangeCalculation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
错误地使用了 ref 对象本身,需改为 opened.current
opened
是 useRef(false)
,直接使用始终为 truthy,导致边界判断与开合阈值计算错误。
- const isEdge = !opened || touch.deltaX.current * startOffset.current < 0
+ const isEdge = !opened.current || touch.deltaX.current * startOffset.current < 0
- const baseNum = opened ? 1 - base : base
+ const baseNum = opened.current ? 1 - base : base
Also applies to: 149-156
🤖 Prompt for AI Agents
In src/packages/swipe/swipe.taro.tsx around lines 120-125 (and similarly at
149-156) the code is using the ref object variable opened instead of its current
value; opened is created via useRef(false) so using opened (truthy) breaks the
edge/open checks—replace uses of opened with opened.current, e.g., change
conditions and any calculations that reference opened to read opened.current so
boundary checks and offset/range calculations use the actual boolean state
stored in the ref.
/* #ifndef dynamic*/ | ||
overflow: auto; | ||
/* #endif */ | ||
background: $color-background-sunken; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
为 dynamic 分支显式指定 overflow,避免不同浏览器默认值差异
当前仅在非 dynamic 分支设置 overflow: auto,dynamic 分支未显式声明,可能因默认值差异导致长列表在某些端无法滚动或出现布局异常。建议对 dynamic 分支也给出明确值,同时统一指令注释格式中的空格。
可改为(在同位置替换整段指令块):
- /* #ifndef dynamic*/
- overflow: auto;
- /* #endif */
+ /* #ifndef dynamic */
+ overflow: auto;
+ /* #endif */
+ /* #ifdef dynamic */
+ overflow: visible;
+ /* #endif */
如 dynamic 模式需要禁滚,改为 overflow: hidden
更稳妥;如只纵向滚动,可使用 overflow-y
精确控制。
为确保构建侧正确处理这些指令,请运行下列脚本快速自查:
🏁 Script executed:
#!/bin/bash
# 查找 dynamic 条件编译指令使用情况
rg -n -C2 '#if(n|def)\s+dynamic' --type=scss
# 粗查构建配置/依赖中是否存在条件编译插件或自定义处理
rg -n -C2 -i 'conditional|ifdef|preprocess|dynamic' package.json
fd -a -H -t f 'taro.config*' | xargs -I{} sh -c "echo '--- {} ---'; sed -n '1,200p' {} | rg -n -i 'define|plugin|dynamic|conditional'"
fd -a -H -t f 'vite.config*' | xargs -I{} sh -c "echo '--- {} ---'; sed -n '1,200p' {} | rg -n -i 'plugin|define|dynamic|conditional'"
fd -a -H -t f 'postcss.config*' | xargs -I{} sh -c "echo '--- {} ---'; sed -n '1,200p' {} | rg -n -i 'plugin|dynamic|conditional'"
Length of output: 2036
使用 SCSS 条件语法替换 C 风格注释
SCSS 不支持 /* #ifndef dynamic */
注释形式的条件编译,导致 overflow: auto;
在所有模式下均生效。请改为 SCSS 的 @if
/@else
语法并显式为 dynamic 分支指定 overflow,例如在 src/packages/timeselect/timeselect.scss
中:
@if not $dynamic {
overflow: auto;
} @else {
overflow: visible;
}
🤖 Prompt for AI Agents
In src/packages/timeselect/timeselect.scss around lines 19 to 22, replace the
C-style conditional comments (/* #ifndef dynamic */ ... /* #endif */) with SCSS
conditional syntax: use an @if/@else block that checks the $dynamic variable and
explicitly sets overflow for both branches (e.g. overflow: auto for not $dynamic
and overflow: visible for $dynamic); ensure $dynamic is a defined boolean
variable or import the file that defines it before this check.
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit