Skip to content

feat: add cursor auto-hide feature with configurable idle delay#81

Merged
j4rviscmd merged 2 commits intomainfrom
feat/cursor-autohide
Mar 27, 2026
Merged

feat: add cursor auto-hide feature with configurable idle delay#81
j4rviscmd merged 2 commits intomainfrom
feat/cursor-autohide

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

Summary

  • Add cursor auto-hide feature that hides the mouse cursor after a configurable period of inactivity
  • Settings are persisted across app restarts and take effect immediately without restarting
  • Interactive overlays (dialogs, menus, dropdowns, BlockNote toolbars) always keep the cursor visible

Changes

New files

  • src/features/editor/lib/cursorAutoHideConfig.ts — defaults, mutable config object, store keys, CSS class name, always-visible selectors
  • src/features/editor/hooks/useCursorAutoHide.ts — two hooks:
    • useCursorAutoHide: settings UI hook (reads/writes configStore, updates cursorAutoHideConfig)
    • useCursorAutoHideEffect: effect-only hook (registers global mousemove/mouseover listeners, reads cursorAutoHideConfig directly so changes take effect without re-render)
  • src/features/settings/ui/CursorAutoHideOption.tsx — settings UI (toggle + 1–30 s delay slider)

Modified files

  • src/features/editor/index.ts — export both hooks
  • src/features/settings/ui/SettingsDialog.tsx — add CursorAutoHideOption section
  • src/App.tsx — call useCursorAutoHideEffect() for app-lifetime mouse listeners
  • src/index.css — add html.cursor-autohide-hidden CSS rules

Design decisions

The hook is split into two (useCursorAutoHide + useCursorAutoHideEffect) to avoid the dual-instance problem: if a single hook managed both settings and listeners, the settings dialog component would register its own listener set that gets destroyed when the dialog closes. By keeping listeners in useCursorAutoHideEffect (called once in App.tsx) and sharing state via the cursorAutoHideConfig mutable object, settings changes from the UI propagate to the effect without any re-render or restart.

- Add useCursorAutoHide hook for persistent settings (enabled + delay)
- Add useCursorAutoHideEffect hook for global mouse listener management
- Split concerns so settings UI changes take effect without app restart
- Add CursorAutoHideOption settings UI (toggle + 1–30 s delay slider)
- Add CSS rules to hide cursor via html.cursor-autohide-hidden class
- Register useCursorAutoHideEffect in App.tsx for app-lifetime listeners
@j4rviscmd j4rviscmd added the enhancement New feature or request label Mar 27, 2026
@j4rviscmd j4rviscmd merged commit de17a4c into main Mar 27, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the feat/cursor-autohide branch March 27, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant