diff --git a/Cargo.lock b/Cargo.lock index 6261d197426..72b4b2900cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2590,6 +2590,7 @@ dependencies = [ "futures", "kit", "once_cell", + "regex", "uuid", "warp", ] diff --git a/ui/src/components/files/upload_progress_bar/mod.rs b/ui/src/components/files/upload_progress_bar/mod.rs index 17724b2bacf..3eddca1ac2c 100644 --- a/ui/src/components/files/upload_progress_bar/mod.rs +++ b/ui/src/components/files/upload_progress_bar/mod.rs @@ -6,6 +6,7 @@ use dioxus_desktop::wry::webview::FileDropEvent; use dioxus_desktop::{use_window, DesktopContext}; use kit::elements::{button::Button, Appearance}; +use crate::utils::get_drag_event::BLOCK_CANCEL_DRAG_EVENT_FOR_LINUX; use crate::utils::{ get_drag_event, verify_valid_paths::{decoded_pathbufs, verify_paths}, @@ -256,6 +257,9 @@ async fn drag_and_drop_function( if verify_paths(&paths) { let new_files_to_upload = decoded_pathbufs(paths); *files_ready_to_upload.write_silent() = new_files_to_upload; + if cfg!(target_os = "linux") { + *BLOCK_CANCEL_DRAG_EVENT_FOR_LINUX.write() = false; + } break; } } diff --git a/ui/src/utils/get_drag_event.rs b/ui/src/utils/get_drag_event.rs index 6f2cbb457e3..350aef6fc21 100644 --- a/ui/src/utils/get_drag_event.rs +++ b/ui/src/utils/get_drag_event.rs @@ -8,3 +8,5 @@ pub fn get_drag_event() -> FileDropEvent { pub static DRAG_EVENT: Lazy> = Lazy::new(|| RwLock::new(FileDropEvent::Cancelled)); + +pub static BLOCK_CANCEL_DRAG_EVENT_FOR_LINUX: Lazy> = Lazy::new(|| RwLock::new(false)); diff --git a/ui/src/webview_config.rs b/ui/src/webview_config.rs index 9dc85456723..868dd1f2f7e 100644 --- a/ui/src/webview_config.rs +++ b/ui/src/webview_config.rs @@ -1,6 +1,6 @@ -use crate::utils::get_drag_event::DRAG_EVENT; +use crate::utils::get_drag_event::{BLOCK_CANCEL_DRAG_EVENT_FOR_LINUX, DRAG_EVENT}; use common::STATIC_ARGS; -use dioxus_desktop::Config; +use dioxus_desktop::{wry::webview::FileDropEvent, Config}; use warp::logging::tracing::log; pub(crate) fn webview_config() -> Config { @@ -25,7 +25,25 @@ pub(crate) fn webview_config() -> Config { ) .with_file_drop_handler(|_w, drag_event| { log::info!("Drag Event: {:?}", drag_event); - *DRAG_EVENT.write() = drag_event; + if cfg!(target_os = "linux") { + match drag_event { + FileDropEvent::Hovered { .. } => { + *BLOCK_CANCEL_DRAG_EVENT_FOR_LINUX.write() = false; + *DRAG_EVENT.write() = drag_event; + } + FileDropEvent::Dropped { .. } => { + *BLOCK_CANCEL_DRAG_EVENT_FOR_LINUX.write() = true; + *DRAG_EVENT.write() = drag_event; + } + _ => { + if !*BLOCK_CANCEL_DRAG_EVENT_FOR_LINUX.read() { + *DRAG_EVENT.write() = FileDropEvent::Cancelled; + } + } + }; + } else { + *DRAG_EVENT.write() = drag_event; + } true }) .with_disable_context_menu(false);