Changed underlying directory attribute to webkitdirectory, fixed attribute parsing to properly toggle it.
This commit is contained in:
1 parent
37a8fb5391
commit
277436f673
5 files changed
+20
-5
No files matched your search
+13
-1
@@ -7,14 +7,26 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn App(cx: Scope) -> Element {
|
fn App(cx: Scope) -> Element {
|
||||||
|
let enable_directory_upload = use_state(cx, || false);
|
||||||
let files_uploaded: &UseRef<Vec<String>> = use_ref(cx, Vec::new);
|
let files_uploaded: &UseRef<Vec<String>> = use_ref(cx, Vec::new);
|
||||||
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
|
label {
|
||||||
|
input {
|
||||||
|
r#type: "checkbox",
|
||||||
|
checked: "{enable_directory_upload}",
|
||||||
|
oninput: move |evt| {
|
||||||
|
enable_directory_upload.set(evt.value.parse().unwrap());
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"Enable directory upload"
|
||||||
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
r#type: "file",
|
r#type: "file",
|
||||||
accept: ".txt, .rs",
|
accept: ".txt, .rs",
|
||||||
multiple: true,
|
multiple: true,
|
||||||
directory: true,
|
directory: **enable_directory_upload,
|
||||||
onchange: |evt| {
|
onchange: |evt| {
|
||||||
to_owned![files_uploaded];
|
to_owned![files_uploaded];
|
||||||
async move {
|
async move {
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ fn get_file_event_for_folder(request: &FileDiologRequest, dialog: rfd::FileDialo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_file_event_for_file(request: &FileDiologRequest, mut dialog: rfd::FileDialog) -> Vec<PathBuf> {
|
fn get_file_event_for_file(
|
||||||
|
request: &FileDiologRequest,
|
||||||
|
mut dialog: rfd::FileDialog,
|
||||||
|
) -> Vec<PathBuf> {
|
||||||
let filters: Vec<_> = request
|
let filters: Vec<_> = request
|
||||||
.accept
|
.accept
|
||||||
.as_deref()
|
.as_deref()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fn module_loader(root_name: &str) -> String {
|
|||||||
let target_id = find_real_id(target);
|
let target_id = find_real_id(target);
|
||||||
if (target_id !== null) {
|
if (target_id !== null) {
|
||||||
const send = (event_name) => {
|
const send = (event_name) => {
|
||||||
const message = serializeIpcMessage("file_diolog", { accept: target.getAttribute("accept"), directory: target.hasAttribute("directory"), multiple: target.hasAttribute("multiple"), target: parseInt(target_id), bubbles: event_bubbles(event_name), event: event_name });
|
const message = serializeIpcMessage("file_diolog", { accept: target.getAttribute("accept"), directory: target.getAttribute("webkitdirectory") === "true", multiple: target.hasAttribute("multiple"), target: parseInt(target_id), bubbles: event_bubbles(event_name), event: event_name });
|
||||||
window.ipc.postMessage(message);
|
window.ipc.postMessage(message);
|
||||||
};
|
};
|
||||||
send("change&input");
|
send("change&input");
|
||||||
|
|||||||
@@ -1098,7 +1098,7 @@ builder_constructors! {
|
|||||||
autofocus: Bool DEFAULT,
|
autofocus: Bool DEFAULT,
|
||||||
capture: String DEFAULT,
|
capture: String DEFAULT,
|
||||||
checked: Bool DEFAULT,
|
checked: Bool DEFAULT,
|
||||||
directory: Bool DEFAULT,
|
directory: Bool "webkitdirectory",
|
||||||
disabled: Bool DEFAULT,
|
disabled: Bool DEFAULT,
|
||||||
form: Id DEFAULT,
|
form: Id DEFAULT,
|
||||||
formaction: Uri DEFAULT,
|
formaction: Uri DEFAULT,
|
||||||
|
|||||||
@@ -143,10 +143,10 @@ mod js {
|
|||||||
autofocus: true,
|
autofocus: true,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
checked: true,
|
checked: true,
|
||||||
directory: true,
|
|
||||||
controls: true,
|
controls: true,
|
||||||
default: true,
|
default: true,
|
||||||
defer: true,
|
defer: true,
|
||||||
|
directory: true,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
formnovalidate: true,
|
formnovalidate: true,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
|
|||||||
Reference in new issue
Block a user