Add null guards for getElementById and uploadDetail in UploadPage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 17:23:31 +08:00
parent 3ad898aaab
commit 08d7402918

View File

@@ -452,6 +452,7 @@ onMounted(async () => {
(newValue) => { (newValue) => {
if (newValue) { if (newValue) {
const inputElement = document.getElementById("fileNameInput"); const inputElement = document.getElementById("fileNameInput");
if (!inputElement) return;
const baseWidth = 20; const baseWidth = 20;
const textWidth = getTextWidth(fileName.value, inputElement); const textWidth = getTextWidth(fileName.value, inputElement);
inputElement.style.width = baseWidth + textWidth + "px"; inputElement.style.width = baseWidth + textWidth + "px";
@@ -461,10 +462,12 @@ onMounted(async () => {
); );
showEdit.value = true; showEdit.value = true;
if (uploadId.value) await filesStore.getUploadDetail(); if (uploadId.value) await filesStore.getUploadDetail();
selectedColumns.value = Array.from( if (uploadDetail.value?.columns) {
{ length: uploadDetail.value.columns.length }, selectedColumns.value = Array.from(
() => columnType[columnType.length - 1], { length: uploadDetail.value.columns.length },
); // Default to "Not Assigned" () => columnType[columnType.length - 1],
); // Default to "Not Assigned"
}
unwatch(); unwatch();
isLoading.value = false; isLoading.value = false;
}); });