- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 173
Site search not focusing on open fixed #1076
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
Conversation
| @babyo77 is attempting to deploy a commit to the Codú Team on Vercel. A member of the Team first needs to authorize it. | 
| Hello @babyo77, thanks for opening your first Pull Request. The maintainers will review this Pull Request and provide feedback as soon as possible. Keep up the great work! | 
| WalkthroughThe changes introduce a feature in the  Changes
 Sequence Diagram(s)sequenceDiagram
    participant User
    participant SearchDialog
    participant InputField
    User->>SearchDialog: Open dialog
    SearchDialog->>InputField: Set timeout to focus
    InputField->>InputField: Focus input
 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
🧹 Outside diff range and nitpick comments (1)
components/ui/Search.tsx (1)
371-379: Approve with suggestions: Auto-focus implementationThe addition of the auto-focus feature is a good improvement for user experience. However, there are a couple of suggestions to enhance its robustness:
Add a cleanup function to cancel the timeout if the component unmounts before the timeout completes. This prevents potential memory leaks.
Consider using a slightly longer delay (e.g., 50ms) instead of 0ms to ensure consistent behavior across different devices and browsers.
Here's a suggested implementation:
useEffect(() => { if (open) { - setTimeout(() => { + const timeoutId = setTimeout(() => { inputRef.current?.focus(); - }, 0); + }, 50); + return () => clearTimeout(timeoutId); } }, [open]);This change ensures proper cleanup and provides a small buffer for more consistent focusing behavior.
| This works great. Thanks babyyo77 | 
| thanks buddy | 
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.
🌮 🦖 LGTM!
| The latest updates on your projects. Learn more about Vercel for Git ↗︎ 
 | 
Fixes #1051
Screen.Recording.2024-10-06.at.10.35.46.PM.mov