Skip to content

Improve Gantt chart zoom, task interactions, and URL state management#3

Open
rightson wants to merge 2 commits into
mainfrom
claude/zoom-and-task-creation-2xxw7
Open

Improve Gantt chart zoom, task interactions, and URL state management#3
rightson wants to merge 2 commits into
mainfrom
claude/zoom-and-task-creation-2xxw7

Conversation

@rightson

@rightson rightson commented Mar 5, 2026

Copy link
Copy Markdown
Owner

Summary

This PR enhances the Gantt chart component with better zoom controls, improved task card interactions, and URL-based project persistence. The changes focus on providing a more intuitive user experience for zooming, task selection, and navigation.

Key Changes

Zoom Improvements

  • Replaced React wheel event handler with native wheel event listener to properly prevent browser zoom on Ctrl+scroll
  • Implemented mouse-position-aware zoom that keeps the date under the cursor fixed while zooming in/out
  • Added support for Shift+scroll horizontal scrolling
  • Made day-level zoom responsive by dynamically sizing columns to fit ~7 days on screen
  • Exported ZOOM_ORDER and ZoomLevel from date utilities for use in zoom calculations
  • Added setZoomLevel action to chart store for direct zoom level control

Task Card Interactions

  • Simplified click handling: single click now selects task, removed double-click delay logic
  • Added dedicated edit button that appears on hover with pencil icon
  • Edit button opens task modal directly without selection delay
  • Added data-task-card attribute for DOM targeting in double-click prevention
  • Improved visual feedback with hover state tracking

Double-Click Task Creation

  • Added safeguards to prevent task creation when clicking on buttons, task cards, or zoom controls
  • Uses DOM traversal to check for interactive elements before creating tasks

URL State Management

  • Projects are now persisted in URL query parameters (?project=<id>)
  • On page load, the app restores the previously selected project from URL
  • Project selection updates the URL automatically
  • New projects are added to the URL on creation

UI/UX Refinements

  • Fixed day-level header labels to stay visible within viewport using sticky positioning
  • Added data-zoom-controls attribute to zoom control container
  • Replaced emoji characters with Unicode escape sequences for consistency
  • Improved header rendering logic with conditional styling for day zoom level

Implementation Details

  • The native wheel event listener uses { passive: false } to allow preventDefault() for Ctrl+scroll
  • Zoom calculations use xToDate() and dateToX() to maintain cursor position during zoom
  • The getZoomConfig() function now accepts optional viewportWidth parameter for responsive day zoom
  • Task card edit button uses SVG icon with proper event handling to prevent propagation

https://claude.ai/code/session_01SBrxHGmgdHfEX7vU5Gr4tv

claude added 2 commits March 4, 2026 08:14
- Ctrl+scroll wheel adjusts time scale instead of browser zoom, with
  anchor-point-aware zooming that keeps the date under cursor stable
- Shift+scroll wheel performs horizontal scrolling of the view
- Default day scale dynamically sizes columns to fit ~7 days on screen
- Day scale sub-header (month label) stays visible by clamping position
  to the viewport instead of centering on the full month span
- Double-click on blank grid area creates a new task; clicks on buttons,
  task cards, or zoom controls are ignored
- Task cards show an edit icon on hover; clicking it opens the modal
  directly without requiring double-click
- Selected project ID is stored in URL query param (?project=<id>) so
  users can share direct links to specific projects

https://claude.ai/code/session_01SBrxHGmgdHfEX7vU5Gr4tv
The browser intercepts Ctrl+wheel for its own zoom at the document level
before the event reaches the container element. Fix by listening on
document in capture phase ({ capture: true }) so we can preventDefault
before the browser processes it. Also stopPropagation to fully suppress
the native zoom. Only activates when mouse is over the Gantt container.

https://claude.ai/code/session_01SBrxHGmgdHfEX7vU5Gr4tv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants