Merge pull request #1917 from spookyvision/patch-1
fix `HasFileData` for `WebDragData`
This commit is contained in:
1 file changed
+9
-14
@@ -10,7 +10,7 @@ use dioxus_html::{
|
|||||||
};
|
};
|
||||||
use js_sys::Array;
|
use js_sys::Array;
|
||||||
use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue};
|
use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue};
|
||||||
use web_sys::{Document, Element, Event, MouseEvent};
|
use web_sys::{Document, DragEvent, Element, Event, MouseEvent};
|
||||||
|
|
||||||
pub(crate) struct WebEventConverter;
|
pub(crate) struct WebEventConverter;
|
||||||
|
|
||||||
@@ -49,10 +49,7 @@ impl HtmlEventConverter for WebEventConverter {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn convert_drag_data(&self, event: &dioxus_html::PlatformEventData) -> dioxus_html::DragData {
|
fn convert_drag_data(&self, event: &dioxus_html::PlatformEventData) -> dioxus_html::DragData {
|
||||||
let event = downcast_event(event);
|
let event = downcast_event(event);
|
||||||
DragData::new(WebDragData::new(
|
DragData::new(WebDragData::new(event.raw.clone().unchecked_into()))
|
||||||
event.element.clone(),
|
|
||||||
event.raw.clone().unchecked_into(),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@@ -462,13 +459,12 @@ impl HasFileData for WebFormData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct WebDragData {
|
struct WebDragData {
|
||||||
element: Element,
|
|
||||||
raw: MouseEvent,
|
raw: MouseEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebDragData {
|
impl WebDragData {
|
||||||
fn new(element: Element, raw: MouseEvent) -> Self {
|
fn new(raw: MouseEvent) -> Self {
|
||||||
Self { element, raw }
|
Self { raw }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,17 +525,16 @@ impl HasFileData for WebDragData {
|
|||||||
#[cfg(not(feature = "file_engine"))]
|
#[cfg(not(feature = "file_engine"))]
|
||||||
let files = None;
|
let files = None;
|
||||||
#[cfg(feature = "file_engine")]
|
#[cfg(feature = "file_engine")]
|
||||||
let files = self
|
let files = self.raw.dyn_ref::<DragEvent>().and_then(|drag_event| {
|
||||||
.element
|
drag_event.data_transfer().and_then(|dt| {
|
||||||
.dyn_ref()
|
dt.files().and_then(|files| {
|
||||||
.and_then(|input: &web_sys::HtmlInputElement| {
|
|
||||||
input.files().and_then(|files| {
|
|
||||||
#[allow(clippy::arc_with_non_send_sync)]
|
#[allow(clippy::arc_with_non_send_sync)]
|
||||||
crate::file_engine::WebFileEngine::new(files).map(|f| {
|
crate::file_engine::WebFileEngine::new(files).map(|f| {
|
||||||
std::sync::Arc::new(f) as std::sync::Arc<dyn dioxus_html::FileEngine>
|
std::sync::Arc::new(f) as std::sync::Arc<dyn dioxus_html::FileEngine>
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
|
});
|
||||||
|
|
||||||
files
|
files
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user