-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Feat ✨ drop menu 支持 filterable 本地搜索 #552
base: master
Are you sure you want to change the base?
The head ref may contain hidden characters: "feat-\u2728-drop-menu-\u652F\u6301-filterable-\u672C\u5730\u641C\u7D22"
Feat ✨ drop menu 支持 filterable 本地搜索 #552
Conversation
feat: ✨ drop-menu 支持 filterable 本地搜索
feat: ✨ drop-menu 支持 filterable 本地搜索 新增的配置参数
…搜索功能 feat: ✨ drop-menu 新增 filterable 本地搜索功能
✅ Deploy Preview for wot-design-uni ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此次更改为 Changes
Possibly related issues
Possibly related PRs
Poem
Tip OpenAI O1 model for chat
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional comments not posted (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/uni_modules/wot-design-uni/components/wd-drop-menu-item/types.ts (1 hunks)
- src/uni_modules/wot-design-uni/components/wd-drop-menu-item/wd-drop-menu-item.vue (5 hunks)
Additional comments not posted (9)
src/uni_modules/wot-design-uni/components/wd-drop-menu-item/types.ts (2)
30-31
: 确保属性名称的拼写正确
dorpMenuItemProps
中的filterable
属性拼写正确,并且默认值为false
,符合预期。
32-33
: 确保属性类型的正确性
filterPlaceholder
属性类型为String
,符合预期。src/uni_modules/wot-design-uni/components/wd-drop-menu-item/wd-drop-menu-item.vue (7)
19-26
: 检查搜索组件的条件渲染
wd-search
组件根据filterable
属性进行条件渲染,并绑定到filterVal
,逻辑正确。
Line range hint
28-35
: 确保选项渲染逻辑的正确性使用
filterOptions
替代直接使用options
,确保只显示过滤后的结果,逻辑正确。
84-85
: 初始化过滤相关的数据属性
filterVal
和filterOptions
的初始化符合预期。
117-131
: 监控选项变化并更新过滤选项
watch
函数监控options
的变化并更新filterOptions
,逻辑正确。
149-160
: 处理过滤值变化的逻辑
handleFilterChange
函数管理过滤逻辑,确保在输入清空时重置filterOptions
,逻辑正确。
162-170
: 封装过滤逻辑
formatFilterOptions
函数封装了过滤逻辑,确保根据labelKey
和filterVal
进行过滤,逻辑正确。
188-193
: 在关闭时清空搜索在关闭菜单时清空搜索框以避免闪烁,逻辑合理。
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.
感谢你的PR!
希望将新增的搜索功能的演示文档补充完整一下。
演示文档在哪里补充? |
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: 0
Outside diff range and nitpick comments (2)
src/uni_modules/wot-design-uni/components/wd-drop-menu-item/wd-drop-menu-item.vue (2)
152-173
: 看起来不错!过滤逻辑实现正确。
handleFilterChange
和formatFilterOptions
函数正确地实现了过滤逻辑。handleFilterChange
处理搜索输入的更改并相应地更新filterOptions
。如果输入为空,则重置filterOptions
以显示所有可用选项。如果输入有值,则调用formatFilterOptions
根据搜索输入过滤选项。
formatFilterOptions
通过检查每个选项的标签是否包含filterVal
来执行实际的过滤。它使用临时数组存储过滤后的选项,然后在下一个 tick 中将其分配给filterOptions
,以在模板中触发响应式更新。对于中小型选项列表,使用
indexOf
进行过滤是一种简单有效的方法。但是,对于较大的数据集,考虑使用更高效的搜索算法或库来优化性能。
183-196
: 看起来不错!选择函数更新正确。更新后的
choose
函数从filterOptions
而不是options
属性中选择一个项目,确保了所选项目基于显示给用户的过滤选项。在发出所选值并关闭下拉菜单后,它会检查
filterVal
是否有值。如果有,它会在 300ms 延迟后调用handleFilterChange
,并传入一个空值来清除搜索输入。这可以防止由于异步更新filterOptions
而可能发生的任何视觉上的闪烁。300ms 的延迟是一个合理的值,可以确保流畅的用户体验。
不过,考虑通过 prop 让延迟时间可配置,以便为不同的用例提供灵活性。
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/uni_modules/wot-design-uni/components/wd-drop-menu-item/wd-drop-menu-item.vue (5 hunks)
Additional comments not posted (4)
src/uni_modules/wot-design-uni/components/wd-drop-menu-item/wd-drop-menu-item.vue (4)
19-26
: 看起来不错!在模板中添加
wd-search
组件以实现搜索功能的方式是正确的。根据filterable
属性有条件地渲染搜索输入框,并通过v-model
指令将输入值绑定到filterVal
数据属性,实现了双向数据绑定。同时,@change
事件处理程序触发handleFilterChange
函数,以便在输入值更改时执行过滤逻辑。
28-28
: 看起来不错!将
v-for
指令更新为遍历filterOptions
而不是options
的更改是正确的。这确保了下拉菜单根据用户的搜索输入显示过滤后的选项。
87-88
: 看起来不错!为过滤功能添加了两个新的响应式引用:
filterVal
和filterOptions
,并使用适当的默认值进行初始化。filterVal
保存搜索输入的当前值,filterOptions
根据搜索输入存储过滤后的选项。这确保了在未提供搜索输入时的正确行为。
120-134
: 看起来不错!为
options
属性添加了一个新的观察器,以根据当前的搜索输入更新filterOptions
。当启用filterable
并且filterVal
有值时,它会调用formatFilterOptions
函数来过滤选项。这确保了下拉菜单始终根据用户的搜索输入和可用选项显示相关选项。
项目中有docs和对应的演示页面。在演示页面补充相应的代码,在docs中补充相应的示例即可 |
已补充文档和示例 |
补充后是有什么不正确? 一直未见更新 |
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
#550
💡 需求背景和解决方案
当下拉选项过多时, 有搜索功能可以更方便的找到目标
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
文档
filterable
和filter-placeholder
属性的说明。