GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [DevTools] [Profiler]: Save profile now working in Firefox (#16612) · react/react@77bb102

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-devtools-shared/src/devtools/views
    • Profiler
      • ProfilingImportExportButtons.js
    • utils.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default function ProfilingImportExportButtons() {
2929
const {profilerStore} = store;
3030

3131
const inputRef = useRef<HTMLInputElement | null>(null);
32+
const downloadRef = useRef<HTMLAnchorElement | null>(null);
3233

3334
const {dispatch: modalDialogDispatch} = useContext(ModalDialogContext);
3435

@@ -38,7 +39,7 @@ export default function ProfilingImportExportButtons() {
3839
return;
3940
}
4041

41-
if (profilingData !== null) {
42+
if (profilingData !== null && downloadRef.current !== null) {
4243
const profilingDataExport = prepareProfilingDataExport(profilingData);
4344
const date = new Date();
4445
const dateString = date
@@ -54,6 +55,7 @@ export default function ProfilingImportExportButtons() {
5455
})
5556
.replace(/:/g, '-');
5657
downloadFile(
58+
downloadRef.current,
5759
`profiling-data.${dateString}.${timeString}.json`,
5860
JSON.stringify(profilingDataExport, null, 2),
5961
);
@@ -114,6 +116,7 @@ export default function ProfilingImportExportButtons() {
114116
onChange={handleFiles}
115117
tabIndex={-1}
116118
/>
119+
<a ref={downloadRef} className={styles.Input} />
117120
<Button
118121
disabled={isProfiling}
119122
onClick={uploadData}
Collapse file

‎packages/react-devtools-shared/src/devtools/views/utils.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/devtools/views/utils.js
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ export function serializeHooksForCopy(hooks: HooksTree | null): string {
178178
// Without this, we would see a "Download failed: network error" failure.
179179
let downloadUrl = null;
180180

181-
export function downloadFile(filename: string, text: string): void {
181+
export function downloadFile(
182+
element: HTMLAnchorElement,
183+
filename: string,
184+
text: string,
185+
): void {
182186
const blob = new Blob([text], {type: 'text/plain;charset=utf-8'});
183187

184188
if (downloadUrl !== null) {
@@ -187,15 +191,10 @@ export function downloadFile(filename: string, text: string): void {
187191

188192
downloadUrl = URL.createObjectURL(blob);
189193

190-
const element = document.createElement('a');
191194
element.setAttribute('href', downloadUrl);
192195
element.setAttribute('download', filename);
193-
element.style.display = 'none';
194-
((document.body: any): HTMLBodyElement).appendChild(element);
195196

196197
element.click();
197-
198-
((document.body: any): HTMLBodyElement).removeChild(element);
199198
}
200199

201200
export function truncateText(text: string, maxLength: number): string {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.