-
Notifications
You must be signed in to change notification settings - Fork 293
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: autocomplete arraysEqual leading to loops #1433
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Poem
🪧 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)
frontend/src/lib/components/Forms/AutocompleteSelect.svelte (1)
Line range hint
76-95
: LGTM! The implementation is robust and handles edge cases well.The enhanced type signature and normalization logic make the function more flexible while maintaining type safety.
Consider these optional improvements:
- The function name could be more descriptive of its enhanced capabilities, e.g.,
areValuesEqual
.- The Set comparison could be simplified using Set operations.
Here's an alternative implementation using Set operations:
function arraysEqual( arr1: string | (string | undefined)[] | null | undefined, arr2: string | (string | undefined)[] | null | undefined ): boolean { const normalize = (val: string | (string | undefined)[] | null | undefined) => { if (typeof val === 'string') return [val]; return val ?? []; }; const a1 = normalize(arr1); const a2 = normalize(arr2); if (a1.length !== a2.length) return false; const set1 = new Set(a1); const set2 = new Set(a2); - for (const value of set1) { - if (!set2.has(value)) return false; - } - return true; + return a1.length === a2.length && + [...set1].every(value => set2.has(value)); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/lib/components/Forms/AutocompleteSelect.svelte
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: startup-docker-compose-test
- GitHub Check: startup-functional-test (3.12)
- GitHub Check: enterprise-startup-functional-test (3.12)
- GitHub Check: migrations-check (3.12)
- GitHub Check: functional-tests (3.12, chromium)
- GitHub Check: enterprise-functional-tests (3.12, chromium)
- GitHub Check: enterprise-startup-docker-compose-test
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (javascript-typescript)
Summary by CodeRabbit
null
,undefined
, and single string inputs in array equality checks