Skip to content

Commit

Permalink
feat: disable outline for mouse users
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardzjl committed Dec 27, 2024
1 parent bd17fc6 commit 05b2bf6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ body {
min-height: 100vh;
}

body:not(.user-is-tabbing) button:focus,
body:not(.user-is-tabbing) input:focus,
body:not(.user-is-tabbing) select:focus,
body:not(.user-is-tabbing) textarea:focus {
outline: none;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
Expand Down
20 changes: 20 additions & 0 deletions web/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'


const handleFirstTab = (e) => {
if (e.keyCode === 9) {
document.body.classList.add('user-is-tabbing');

window.removeEventListener('keydown', handleFirstTab);
window.addEventListener('mousedown', handleMouseDownOnce);
}
}

const handleMouseDownOnce = () => {
document.body.classList.remove('user-is-tabbing');

window.removeEventListener('mousedown', handleMouseDownOnce);
window.addEventListener('keydown', handleFirstTab);
}

window.addEventListener('keydown', handleFirstTab);


createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
Expand Down

0 comments on commit 05b2bf6

Please sign in to comment.