ui: plan 01-27 done #1
File diff suppressed because it is too large
Load Diff
@@ -194,8 +194,14 @@
|
|||||||
async function onSyntheticFileChange(
|
async function onSyntheticFileChange(
|
||||||
event: Event & { currentTarget: HTMLInputElement },
|
event: Event & { currentTarget: HTMLInputElement },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
// Capture the element synchronously: `event.currentTarget`
|
||||||
|
// is nulled by the time any of the awaits below resolve, and
|
||||||
|
// reaching for it from the `finally` block then throws
|
||||||
|
// "null is not an object". The reset still has to happen so
|
||||||
|
// re-selecting the same file fires `change` again.
|
||||||
|
const input = event.currentTarget;
|
||||||
syntheticError = null;
|
syntheticError = null;
|
||||||
const file = event.currentTarget.files?.[0];
|
const file = input.files?.[0];
|
||||||
if (file === undefined) return;
|
if (file === undefined) return;
|
||||||
try {
|
try {
|
||||||
const text = await file.text();
|
const text = await file.text();
|
||||||
@@ -213,7 +219,7 @@
|
|||||||
syntheticError = "failed to load synthetic report";
|
syntheticError = "failed to load synthetic report";
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
event.currentTarget.value = "";
|
input.value = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user