fix if container not created
This commit is contained in:
parent
34780a741a
commit
dcc9265adb
23
main.js
23
main.js
@ -509,10 +509,7 @@
|
||||
}
|
||||
else if (variant == "h") {
|
||||
let filesContainer = document.querySelector(`[data-container="${fileInputs[inputName].h}"]`)
|
||||
fileListContainer = filesContainer.querySelector(`.file-list-container`)
|
||||
if (fileListContainer == null) {
|
||||
filesContainer.append(makeFileListContainer())
|
||||
}
|
||||
fileListContainer = getFileListContainer(filesContainer)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -624,6 +621,16 @@
|
||||
classes: "file-list-container"
|
||||
})
|
||||
}
|
||||
|
||||
function getFileListContainer(filesContainer) {
|
||||
let fileListContainer = filesContainer.querySelector(".file-list-container")
|
||||
if (fileListContainer == null) {
|
||||
fileListContainer = makeFileListContainer()
|
||||
filesContainer.append(fileListContainer)
|
||||
}
|
||||
|
||||
return fileListContainer
|
||||
}
|
||||
|
||||
function makeHandleFilesFunc() {
|
||||
let storedFiles = []
|
||||
@ -647,11 +654,7 @@
|
||||
|
||||
if (variant) {
|
||||
let [_, filesContainer] = getContainersByVariant(variant, getAttachmentIndex(this))
|
||||
fileListContainer = filesContainer.querySelector(".file-list-container")
|
||||
if (fileListContainer == null) {
|
||||
fileListContainer = makeFileListContainer()
|
||||
filesContainer.append(fileListContainer)
|
||||
}
|
||||
fileListContainer = getFileListContainer(filesContainer)
|
||||
}
|
||||
else {
|
||||
fileListContainer = this.parentElement.parentElement.querySelector(".file-list-container")
|
||||
@ -828,7 +831,7 @@
|
||||
let [from, to] = getContainersByVariant(this.value, attachmentIndex)
|
||||
let newFiles = [...from.querySelectorAll(`.file-container-new`)]
|
||||
for (const newFile of newFiles) {
|
||||
to.querySelector(`.file-list-container`).append(newFile)
|
||||
getFileListContainer(to).append(newFile)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user