-
Notifications
You must be signed in to change notification settings - Fork 2
Add '/' keyboard shortcut to focus search input in dashboard #9
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
base: main
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
Error Handling for Missing Search InputLocation: The current implementation silently fails if the search input selector doesn't match any element, which could make debugging difficult if the HTML structure changes. Current code: if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey) {
const searchInput = document.querySelector('.head .search input[type="search"]');
if (searchInput) {
e.preventDefault();
searchInput.focus();
}
}Suggested improvement: if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey) {
const searchInput = document.querySelector('.head .search input[type="search"]');
if (searchInput) {
e.preventDefault();
searchInput.focus();
} else {
console.warn('Search input not found - keyboard shortcut unavailable');
}
}Benefits:
|
almog-lv
left a comment
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.
Consider extracting the JavaScript code to an external file (e.g., js/dashboard.js) for better code organization and maintainability. This would separate concerns and make the HTML cleaner, especially as more interactive features are added to the dashboard.
| } | ||
| }); | ||
| </script> | ||
| </body> |
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.
Consider extracting the JavaScript code to an external file (e.g., js/dashboard.js) for better code organization and maintainability. This would separate concerns and make the HTML cleaner, especially as more interactive features are added to the dashboard.
For example:
- Create
js/dashboard.jswith the keyboard shortcut logic - Replace the inline script with
<script src="js/dashboard.js"></script> - This approach makes the code more modular and easier to test
PR Type
Enhancement
Description
Add keyboard shortcut functionality to dashboard
Implement '/' key to focus search input
Include input field detection to prevent conflicts
Diagram Walkthrough
File Walkthrough
index.html
Add keyboard shortcut for search focusindex.html