Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: custom actions context menu #247

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

that-one-arab
Copy link
Contributor

No description provided.

UI implementation of context menu, no business logic yet. WIP.
…s styling be consistent in UI

Purpose is consistency. any inconsistent border radius, even by small pixel differences, will look "off" to the user.
@that-one-arab that-one-arab changed the title Feature custom actions context menu WIP: custom actions context menu Feb 4, 2025
Purpose is to remain consistent across codebase
@that-one-arab that-one-arab force-pushed the feature_custom_actions_context_menu branch from 37f0b1e to e5ecea7 Compare February 4, 2025 05:28
Detecting whether an event was right clicked or not in a clean manner solves a big hurdle.
Not sure why it was of type button in the first place, but this fixes it.
This commit demonstrates a POC for editing an event and inner functionality of how the context menu will interact with an event in its draft state.
@that-one-arab that-one-arab force-pushed the feature_custom_actions_context_menu branch from de277d4 to 5acb05d Compare February 7, 2025 04:51
the purpose is to prevent an additional action from occurring when user tries to close the context menu by clicking outside. Mimicking user expecations.
@tyler-dane
Copy link
Contributor

tyler-dane commented Feb 8, 2025

Hey @that-one-arab , I see you're finding solutions to make this work. But I'm concerned that we're reinventing the wheel and adding unnecessary complexity along the way. Specifically, calculating the x,y coordiantes, creating context menu, and adding an invisible backdrop.

Please check out floating-ui, which can solve a lot of these problems out-of-the-box and in a more reusable fashion. We're already using this for the forms, and could use it for other elements like tooltips (for shortcuts) and select menus (for time inputs).

Although what you have so far might work, I'd rather go with the more resusable solution that requires less code and maintenance.

If we can use a good library like floating UI to allow us to just focus on the unique aspects of a context menu in Compass (its styling and elements), that'd be a big win

@tyler-dane tyler-dane linked an issue Feb 8, 2025 that may be closed by this pull request
13 tasks
@that-one-arab
Copy link
Contributor Author

Hey @that-one-arab , I see you're finding solutions to make this work. But I'm concerned that we're reinventing the wheel and adding unnecessary complexity along the way. Specifically, calculating the x,y coordiantes, creating context menu, and adding an invisible backdrop.

Please check out floating-ui, which can solve a lot of these problems out-of-the-box and in a more reusable fashion. We're already using this for the forms, and could use it for other elements like tooltips (for shortcuts) and select menus (for time inputs).

Although what you have so far might work, I'd rather go with the more resusable solution that requires less code and maintenance.

If we can use a good library like floating UI to allow us to just focus on the unique aspects of a context menu in Compass (its styling and elements), that'd be a big win

Agreed. I wasn't aware of the library, I am checking it out and I like the reliability of it and the complex positioning scenarios it handles out of the box. I will refactor the PR accordingly.

Floating UI is a well tested library that handles a lot of nuances and edge cases with floating elements positioning
@@ -47,6 +47,8 @@ export const MainGridEvents = ({ measurements, weekProps }: Props) => {

const editTimedEvent = (event: Schema_GridEvent) => {
dispatch(
// TODO: `actions.startDragging` is confusing, it appears to mix concerns for both dragging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Some of my changes from my current draft PR will improve how this works

Copy link
Contributor

@tyler-dane tyler-dane Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS This comment is just be a harmless note-to-self in a draft PR, but it's a good opportunity to share my thoughts on comments in general: https://docs.compasscalendar.com/docs/contribute/convention-guide#comments.

Go ahead and keep using TODO comments during your WIP PRs if it helps your workflow, but please remove them before submitting the PR. If they're still relevant at the time of publishing your PR, you could add an issue or inline PR comment like I'm doing here so we don't miss out on your thoughts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tyler-dane Nice catch yes I wasn't aware about the comments policy, and I happen to agree to your philosophy regarding it. I'll make sure to clean it up.

- Replace `event` local state with draft event redux state as the source of truth for the selected event
- Handle setting and clearing the right-clicked event as the draft event
- rename `event` to `gridEvent` to avoid confusion with DOM events
- TS typing and error fixing
…ent is right clicked

This is a crucial line. It allows us to handle right clicks separately (EG: Displaying a context menu)
- Implement context menu edit priority
- Decouple `ContextMenu` and create `ContextMenuItems` to separate floating ui menu logic from menu items business logic
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.

Create actions menu and render when right-clicking an event
2 participants