fix(theme): prevent dark mode toggle on search input keypress#944
Conversation
|
Someone is attempting to deploy a commit to the abhinavvuco-8934's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Ronak120703 This PR is incomplete and needs proper documentation before it can be reviewed.
Please update the PR with:
Once that’s done, we can proceed with the technical review. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@Ronak120703 Nice fix , this correctly prevents theme toggling while typing in inputs. Good handling of edge cases like A couple of small improvements i made to this to make it more robust:
|
Description & Technical Solution
Problem
Pressing the
Dkey anywhere in the app was triggering the theme toggle, even when the user was typing inside input fields such as the search modal. This caused a poor user experience, as users were unable to type normally (e.g., typing “d” would switch themes instead of appearing in the input).Impact
Solution
Added a guard in the global
keydownlistener to detect when the user is interacting with input elements (input,textarea,select, and contenteditable fields).If the event originates from a typing context, the theme toggle logic is skipped. Otherwise, pressing
Dcontinues to toggle between light and dark mode as intended.This ensures:
Checklist
Closes: #943