From 94fb3c2c08a3545705835194266cebbcb953c04a Mon Sep 17 00:00:00 2001 From: Anastasia Smirnova Date: Wed, 16 Oct 2019 12:34:06 +0300 Subject: Upload should preserve MIMEType after first selection (#11745) * Upload should preserve MIMEType after first selection Fix #11698 Automated test is not run locally, need to continue with it * Remove unused imports * Add sleep time in testing purposes * Getting a new instance of an input, after file is downloaded Exclude IE from tests. Throws https://stackoverflow.com/questions/23883071/unhandled-alert-exception-modal-dialog-present-selenium , but checked manually and it works --- client/src/main/java/com/vaadin/client/ui/VUpload.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'client') diff --git a/client/src/main/java/com/vaadin/client/ui/VUpload.java b/client/src/main/java/com/vaadin/client/ui/VUpload.java index 56532b4a19..2f4b62a47f 100644 --- a/client/src/main/java/com/vaadin/client/ui/VUpload.java +++ b/client/src/main/java/com/vaadin/client/ui/VUpload.java @@ -121,6 +121,8 @@ public class VUpload extends SimplePanel { private boolean immediateMode; + private String acceptMimeTypes; + private Hidden maxfilesize = new Hidden(); /** For internal use only. May be removed or replaced in the future. */ @@ -254,6 +256,9 @@ public class VUpload extends SimplePanel { fu = new VFileUpload(); fu.setName(paintableId + "_file"); fu.getElement().setPropertyBoolean("disabled", !enabled); + if (acceptMimeTypes != null && !acceptMimeTypes.isEmpty()) { + InputElement.as(fu.getElement()).setAccept(acceptMimeTypes); + } panel.add(fu); panel.add(submitButton); if (isImmediateMode()) { @@ -424,5 +429,6 @@ public class VUpload extends SimplePanel { } else { InputElement.as(fu.getElement()).setAccept(acceptMimeTypes); } + this.acceptMimeTypes = acceptMimeTypes; } } -- cgit v1.2.3