fix: search input initialization and re-focus bug#2148
fix: search input initialization and re-focus bug#2148nnecec wants to merge 1 commit intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThis pull request enhances the Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can customize the tone of the review comments and chat replies.Configure the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/composables/useGlobalSearch.ts (1)
60-67: Consider extracting focused input detection into a reusable helper.The logic for detecting whether a search input is focused (lines 60-67) duplicates the pattern from
getFocusedSearchInputValue(lines 22-24). Extracting a smallisSearchInputFocused()helper would improve maintainability.♻️ Proposed refactor
+const isSearchInputFocused = (): boolean => { + if (!import.meta.client) return false + const active = document.activeElement + if (!(active instanceof HTMLInputElement)) return false + return active.type === 'search' || active.name === 'q' +} + const getFocusedSearchInputValue = () => { - if (!import.meta.client) return '' - - const active = document.activeElement - if (!(active instanceof HTMLInputElement)) return '' - if (active.type !== 'search' && active.name !== 'q') return '' - return active.value + if (!isSearchInputFocused()) return '' + return (document.activeElement as HTMLInputElement).value }Then in the watcher:
- if (import.meta.client) { - const active = document.activeElement - if ( - active instanceof HTMLInputElement && - (active.type === 'search' || active.name === 'q') - ) { - return - } - } + if (isSearchInputFocused()) return
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ecd4a617-b5c7-4a12-93b5-29da7a115b93
📒 Files selected for processing (1)
app/composables/useGlobalSearch.ts
🔗 Linked issue
no issue
🧭 Context
no context
📚 Description
3.19.1.mp4
Fixed two issues: