From 81dfaa0602e8928ce0d477604740dc7affacdcd0 Mon Sep 17 00:00:00 2001 From: Hardik Dharmani Date: Tue, 9 May 2023 02:10:31 +0530 Subject: [PATCH] dialog_widget: Update `get_current_values` function. Updated `get_current_values` function to not include undefined keys in current_values object and if the input field is of type file and a file is selected then set the value equal to file object. --- web/src/dialog_widget.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.ts index 9bcf89bb14..84ecf6401f 100644 --- a/web/src/dialog_widget.ts +++ b/web/src/dialog_widget.ts @@ -147,7 +147,14 @@ export function launch(conf: WidgetConfig): void { const current_values: Record = {}; $inputs.each(function () { const property_name = $(this).attr("name")!; - current_values[property_name] = $(this).val(); + if (property_name) { + if ($(this).is("input[type='file']") && $(this).prop("files")?.length) { + // If the input is a file input and a file has been selected, set value to file object + current_values[property_name] = $(this).prop("files")[0]; + } else { + current_values[property_name] = $(this).val(); + } + } }); return current_values; }