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") {
|
else if (variant == "h") {
|
||||||
let filesContainer = document.querySelector(`[data-container="${fileInputs[inputName].h}"]`)
|
let filesContainer = document.querySelector(`[data-container="${fileInputs[inputName].h}"]`)
|
||||||
fileListContainer = filesContainer.querySelector(`.file-list-container`)
|
fileListContainer = getFileListContainer(filesContainer)
|
||||||
if (fileListContainer == null) {
|
|
||||||
filesContainer.append(makeFileListContainer())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -624,6 +621,16 @@
|
|||||||
classes: "file-list-container"
|
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() {
|
function makeHandleFilesFunc() {
|
||||||
let storedFiles = []
|
let storedFiles = []
|
||||||
@ -647,11 +654,7 @@
|
|||||||
|
|
||||||
if (variant) {
|
if (variant) {
|
||||||
let [_, filesContainer] = getContainersByVariant(variant, getAttachmentIndex(this))
|
let [_, filesContainer] = getContainersByVariant(variant, getAttachmentIndex(this))
|
||||||
fileListContainer = filesContainer.querySelector(".file-list-container")
|
fileListContainer = getFileListContainer(filesContainer)
|
||||||
if (fileListContainer == null) {
|
|
||||||
fileListContainer = makeFileListContainer()
|
|
||||||
filesContainer.append(fileListContainer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fileListContainer = this.parentElement.parentElement.querySelector(".file-list-container")
|
fileListContainer = this.parentElement.parentElement.querySelector(".file-list-container")
|
||||||
@ -828,7 +831,7 @@
|
|||||||
let [from, to] = getContainersByVariant(this.value, attachmentIndex)
|
let [from, to] = getContainersByVariant(this.value, attachmentIndex)
|
||||||
let newFiles = [...from.querySelectorAll(`.file-container-new`)]
|
let newFiles = [...from.querySelectorAll(`.file-container-new`)]
|
||||||
for (const newFile of newFiles) {
|
for (const newFile of newFiles) {
|
||||||
to.querySelector(`.file-list-container`).append(newFile)
|
getFileListContainer(to).append(newFile)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user