-
Notifications
You must be signed in to change notification settings - Fork 340
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
fix: resolve block search exceptions #995
fix: resolve block search exceptions #995
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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
🧹 Nitpick comments (1)
packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue (1)
110-121
: Consider performance optimizations for the search implementation.While the current implementation works, consider these improvements:
- Memoize the RegExp pattern creation to avoid rebuilding it on every filter operation
- Consider adding Unicode normalization for better Chinese character matching
- Add debouncing for large lists to prevent performance issues
Here's a suggested optimization:
+ import { useDebounceFn } from '@vueuse/core' + import { memoize } from 'lodash-es' + const createSearchPattern = memoize((searchValue) => + new RegExp(escapeRegExp(searchValue), 'i') + ) const filteredBlocks = computed(() => { if (!state.searchValue) { return state.blockList } const searchValue = state.searchValue.trim() - const pattern = new RegExp(escapeRegExp(searchValue), 'i') + const pattern = createSearchPattern(searchValue) return state.blockList.filter((block) => { return pattern.test(block?.name_cn) || pattern.test(block?.label) || pattern.test(block?.description) }) })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue
(6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (4)
packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue (4)
Line range hint
13-20
: LGTM! Good separation of concerns.The change from direct state binding to using a computed property improves the component's reactivity and maintainability.
27-27
: LGTM! Good use of utility functions.The addition of
escapeRegExp
is essential for safely handling special characters in search patterns, which directly addresses the Chinese character support requirement.Also applies to: 40-40, 84-85
274-274
: LGTM! Proper exposure of the computed property.The filteredBlocks computed property is correctly exposed to the template.
118-120
: Verify Chinese character search functionality.While the implementation looks correct, please ensure comprehensive testing with:
- Various Chinese characters (simplified and traditional)
- Mixed Chinese and English search terms
- Special characters within Chinese text
- Edge cases (empty search, whitespace-only search)
✅ Verification successful
Implementation verified for Chinese character search support
The search implementation in BlockGroupPanel.vue follows established patterns in the codebase for handling Chinese characters. The code:
- Correctly handles Chinese characters through name_cn field
- Provides multilingual support with label and description fallbacks
- Uses proper error handling with optional chaining
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for existing test files related to block search fd -e spec.js -e spec.ts -e test.js -e test.ts . | grep -i "block.*search\|search.*block" # Look for existing Chinese character handling in the codebase rg -l "[\u4e00-\u9fff]" --type ts --type vueLength of output: 166
Script:
#!/bin/bash # Add Vue file type and search for Chinese characters rg --type-add 'vue:*.vue' -l '[\u4e00-\u9fff]' --type vue # Search for block-related test files more broadly fd -e spec.js -e spec.ts -e test.js -e test.ts . | grep -i "block" # Look for BlockGroupPanel test file specifically fd BlockGroupPanel -e spec.js -e spec.ts -e test.js -e test.ts . # Search for existing search functionality tests rg -l "test|describe|it.*search" --type ts --type jsLength of output: 17167
This reverts commit fee84e6.
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
物料 -> 区块 -> 添加区块【区块列表页】:关键字搜索不支持中文,搜索结果异常
Issue Number: N/A
What is the new behavior?
物料 -> 区块 -> 添加区块【区块列表页】:关键字搜索添加中文支持
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Performance