Skip to content

Commit

Permalink
[Fix] Dispatch click event instead of click() (#2345)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta committed Oct 2, 2023
1 parent cf9cf21 commit 6ef400d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/utils/src/export-utils.ts
Expand Up @@ -138,7 +138,15 @@ export function downloadFile(fileBlob: Blob, fileName: string) {
link.setAttribute('download', fileName);

document.body.appendChild(link);
link.click();
// in some cases where maps are embedded, e.g. need to
// create and dispatch an event so that the browser downloads
// the file instead of navigating to the url
const evt = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
});
link.dispatchEvent(evt);
document.body.removeChild(link);
URL.revokeObjectURL(url);
}
Expand Down

0 comments on commit 6ef400d

Please sign in to comment.