Fix drag-to-create event bugs and improve week view UX
- Restrict drag-to-create to left-click only (ignore right-clicks) - Prevent drag-to-create when clicking on existing events - Remove unnecessary right-click context menu from week view empty spaces 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -120,6 +120,11 @@ pub fn week_view(props: &WeekViewProps) -> Html {
|
||||
let onmousedown = {
|
||||
let drag_state = drag_state_clone.clone();
|
||||
Callback::from(move |e: MouseEvent| {
|
||||
// Only handle left-click (button 0)
|
||||
if e.button() != 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate Y position relative to day column container
|
||||
// Use layer_y which gives coordinates relative to positioned ancestor
|
||||
let relative_y = e.layer_y() as f64;
|
||||
@@ -197,18 +202,6 @@ pub fn week_view(props: &WeekViewProps) -> Html {
|
||||
html! {
|
||||
<div
|
||||
class={classes!("week-day-column", if is_today { Some("today") } else { None })}
|
||||
oncontextmenu={
|
||||
if let Some(callback) = &props.on_calendar_context_menu {
|
||||
let callback = callback.clone();
|
||||
let date = *date;
|
||||
Some(Callback::from(move |e: web_sys::MouseEvent| {
|
||||
e.prevent_default();
|
||||
callback.emit((e, date));
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
{onmousedown}
|
||||
{onmousemove}
|
||||
{onmouseup}
|
||||
@@ -250,6 +243,12 @@ pub fn week_view(props: &WeekViewProps) -> Html {
|
||||
})
|
||||
};
|
||||
|
||||
let onmousedown_event = {
|
||||
Callback::from(move |e: MouseEvent| {
|
||||
e.stop_propagation(); // Prevent drag-to-create from starting on event clicks
|
||||
})
|
||||
};
|
||||
|
||||
let oncontextmenu = {
|
||||
if let Some(callback) = &props.on_event_context_menu {
|
||||
let callback = callback.clone();
|
||||
@@ -310,6 +309,7 @@ pub fn week_view(props: &WeekViewProps) -> Html {
|
||||
)}
|
||||
{onclick}
|
||||
{oncontextmenu}
|
||||
onmousedown={onmousedown_event}
|
||||
>
|
||||
<div class="event-title">{event.summary.as_ref().unwrap_or(&"Untitled".to_string())}</div>
|
||||
{if !is_all_day {
|
||||
|
||||
Reference in New Issue
Block a user