Skip to content

⚠️ Feat(POC): Trigger event actions on intuitive mouse events#253

Closed
tyler-dane wants to merge 22 commits intomainfrom
fix/199-sidebar-order
Closed

⚠️ Feat(POC): Trigger event actions on intuitive mouse events#253
tyler-dane wants to merge 22 commits intomainfrom
fix/199-sidebar-order

Conversation

@tyler-dane
Copy link
Contributor

@tyler-dane tyler-dane commented Feb 6, 2025

This is a proof-of-concept of how to trigger events using global event listeners and state, with a focus on mouse events. It provides a UX that is more aligned with user expectations. It also enables future enhancements and fixes, including #199.

Summary

Further separates concerns between mouse, clicks, events, and drafts.

1. Delegates form display to the floating-ui library

Whenever a user clicks on a grid, there are many potential next steps that might occur: creating a new event, closing the previous event form, dragging, or resizing. We previously had to add conditionals into child components (like the header and sidebar) that would check the state of the app so help us identify which scenario we were in at the time of the click.

Now we're using floating-ui's onOpenChange callback and useDismiss hook to do that for us. We configured the forms to close whenever the user clicks ESC or clicks outside of the form. This allows us to stop polluting our components with form-checking behavior.

2. Decouples the form and draft.

We were previously tracking whether an event should open its form by adding an isOpen boolean to every grid draft. The downside of that approach is that although only one form can be open at a time, we had to add that property to every event. Thanks to the change above, we could now accomplish this using one state, isEventForm, that is separate from individual events. This makes event state more minimal and also simplifies event creation and teardown.

3. Changes mouse listeners and events

This is how mouse handlers previously worked from a user's perspective:

Action Result
mouse down created new event and immediately started resizing the end date
mouse down on grid when drafting a different event draft discarded
mouseup form opened
click n/a

This is how they work now:

Action Result
mouse down nothing
move while mouse is down start resizing
mouse down on grid when drafting a different event n/a
mouseup after mousing down and moving resizing stops, form opens
click on grid new draft created and form opens
click on grid when drafting a different event draft discarded

using floating-ui's API rather than managing ourselves
…with Schema_Event in Sidebar components and hooks
@tyler-dane tyler-dane changed the title ♻️ Refactor: close forms on ESC or outside press ♻️ Refactor: close forms on ESC or outside click Feb 6, 2025
@tyler-dane tyler-dane changed the title ♻️ Refactor: close forms on ESC or outside click 🐛 Fix: close forms on ESC or outside click Feb 7, 2025
@tyler-dane tyler-dane linked an issue Feb 8, 2025 that may be closed by this pull request
works:
- click and then move to start resizing
- empty click closes open form

broke: repeating the above and lots of other cases
@tyler-dane tyler-dane changed the title 🐛 Fix: close forms on ESC or outside click ✨ Feat: Trigger event actions on intuitive mouse events Feb 9, 2025
…component

this implementation is based on measureing the grid and computing the position of the mouse (which is probably unnecessarily complicated)

works: initial drag and move and click out using
…ual grid measurements

this simplifies the click handling and discarding logic
This refactoring extracts separate callback methods for handling draft event scenarios like resizing, dragging, and shortcut/click interactions, improving code readability and reducing complexity in the main handleChange method.
This change extracts the form-related logic from useDraftUtil into a new useDraftForm hook, improving separation of concerns and making the draft utility more modular. The new hook encapsulates form open/close behavior and form props management.
This commit introduces a comprehensive useDraft hook that consolidates draft event handling logic, replacing the previous useDraftUtil approach. The new hook:

- Manages draft state and interactions
- Handles dragging, resizing, and event creation
- Provides utility methods for draft event manipulation
- Improves code organization and modularity
…arity

This commit introduces a new useDraftActions hook that centralizes draft event management actions, further modularizing the draft event handling logic. Key changes include:

- Extracting complex draft-related methods from useDraft
- Improving separation of concerns
- Simplifying the main draft hook's implementation
- Maintaining consistent state management across draft interactions
@tyler-dane tyler-dane force-pushed the fix/199-sidebar-order branch from 6329a8c to 88c51c8 Compare February 10, 2025 14:47
This change updates the draft event creation process in the useShortcuts hook by adding default event properties, including:
- Setting an unassigned priority
- Adding default positioning information
- Ensuring consistent event structure when creating draft events via shortcuts
This update improves the draft event creation process by:
- Adding a new utility function for creating all-day draft events
- Refactoring mouse handlers to support different grid click scenarios
- Introducing more robust click and draft state management
- Adding a selector to track resizing state
- Implementing a stop resizing action in the draft slice
partially working. here is what's wrong
- resizing: opens new draft
- C shortcut sometimes gets the wrong width
- when clicking out, the original draft is still in dragging state
@tyler-dane tyler-dane changed the title ✨ Feat: Trigger event actions on intuitive mouse events ⚠️ Feat(POC): Trigger event actions on intuitive mouse events Feb 13, 2025
@tyler-dane
Copy link
Contributor Author

closing in favor of #255

@tyler-dane tyler-dane closed this Feb 18, 2025
@tyler-dane tyler-dane linked an issue Feb 18, 2025 that may be closed by this pull request
2 tasks
@tyler-dane tyler-dane deleted the fix/199-sidebar-order branch September 25, 2025 00:26
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.

Refactor draft hooks

1 participant