From 77bb1023986225a12aaa1b45b85703df5deaf95a Mon Sep 17 00:00:00 2001 From: Hristo Kanchev Date: Tue, 3 Sep 2019 17:35:12 +0200 Subject: [PATCH 1/3] [DevTools] [Profiler]: Save profile now working in Firefox (#16612) * Added anchor dom element in order to successfully download profiling data. * Reworked downloadFile to accept a DOMElement in order for FF to successfully download profiling data. * Prettify downloadFile changes. --- .../views/Profiler/ProfilingImportExportButtons.js | 5 ++++- .../react-devtools-shared/src/devtools/views/utils.js | 11 +++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js b/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js index 376afcf45e883..8f6b40199ea2e 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js @@ -29,6 +29,7 @@ export default function ProfilingImportExportButtons() { const {profilerStore} = store; const inputRef = useRef(null); + const downloadRef = useRef(null); const {dispatch: modalDialogDispatch} = useContext(ModalDialogContext); @@ -38,7 +39,7 @@ export default function ProfilingImportExportButtons() { return; } - if (profilingData !== null) { + if (profilingData !== null && downloadRef.current !== null) { const profilingDataExport = prepareProfilingDataExport(profilingData); const date = new Date(); const dateString = date @@ -54,6 +55,7 @@ export default function ProfilingImportExportButtons() { }) .replace(/:/g, '-'); downloadFile( + downloadRef.current, `profiling-data.${dateString}.${timeString}.json`, JSON.stringify(profilingDataExport, null, 2), ); @@ -114,6 +116,7 @@ export default function ProfilingImportExportButtons() { onChange={handleFiles} tabIndex={-1} /> +