Skip to content

fix: 修复 Select OptionList 中 optionInner 未定义导致的报错#2206

Merged
saint3347 merged 1 commit intomasterfrom
fix-select-optionlist-undefined-error
Jan 8, 2026
Merged

fix: 修复 Select OptionList 中 optionInner 未定义导致的报错#2206
saint3347 merged 1 commit intomasterfrom
fix-select-optionlist-undefined-error

Conversation

@saint3347
Copy link
Contributor

@saint3347 saint3347 commented Jan 8, 2026

Summary

修复了 Select 组件 OptionList 中的运行时错误:

  • hoverMove 方法中访问 this.optionInner.style 时,可能因为 DOM ref 尚未初始化而导致 Cannot read properties of undefined (reading 'style') 错误
  • 在方法开头添加了空值检查 if (!this.optionInner) return,与 handleScroll 方法保持一致的防御性编程模式

修复位置

src/Select/OptionList.tsx:69

影响范围

  • 仅修复异常场景,不影响正常功能
  • 无 Breaking Change

Test plan

  • 验证 Select 组件正常渲染和交互
  • 验证键盘操作(上下箭头)时不会报错
  • 验证埋点错误不再出现

🤖 Generated with Claude Code

修复了在 hoverMove 方法中访问 this.optionInner.style 时,可能因为 DOM ref 尚未初始化而导致的 "Cannot read properties of undefined (reading 'style')" 错误。

在方法开头添加了空值检查,与 handleScroll 方法保持一致的防御性编程模式。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@saint3347 saint3347 merged commit ac731d3 into master Jan 8, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant