mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
fix file selector for IE11
This commit is contained in:
parent
8db7499f5a
commit
6384702863
@ -146,6 +146,7 @@ export class Platform {
|
||||
openFile(mimeType = null) {
|
||||
const input = document.createElement("input");
|
||||
input.setAttribute("type", "file");
|
||||
input.className = "hidden";
|
||||
if (mimeType) {
|
||||
input.setAttribute("accept", mimeType);
|
||||
}
|
||||
@ -153,6 +154,7 @@ export class Platform {
|
||||
const checkFile = () => {
|
||||
input.removeEventListener("change", checkFile, true);
|
||||
const file = input.files[0];
|
||||
this._container.removeChild(input);
|
||||
if (file) {
|
||||
resolve({name: file.name, blob: BlobHandle.fromFile(file)});
|
||||
} else {
|
||||
@ -161,6 +163,8 @@ export class Platform {
|
||||
}
|
||||
input.addEventListener("change", checkFile, true);
|
||||
});
|
||||
// IE11 needs the input to be attached to the document
|
||||
this._container.appendChild(input);
|
||||
input.click();
|
||||
return promise;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user