forked from MapComplete/MapComplete
Fix jumping up when a question is answered
This commit is contained in:
parent
7f6611f9d5
commit
6cb5ced361
1 changed files with 12 additions and 6 deletions
|
@ -31,13 +31,19 @@ export default abstract class BaseUIElement {
|
|||
throw "SEVERE: could not attach UIElement to " + divId
|
||||
}
|
||||
|
||||
while (element.firstChild) {
|
||||
//The list is LIVE so it will re-index each call
|
||||
element.removeChild(element.firstChild)
|
||||
let alreadyThere = false
|
||||
const elementToAdd = this.ConstructElement()
|
||||
const childs = Array.from(element.childNodes)
|
||||
for (const child of childs) {
|
||||
if (child === elementToAdd) {
|
||||
alreadyThere = true
|
||||
continue
|
||||
}
|
||||
element.removeChild(child)
|
||||
}
|
||||
const el = this.ConstructElement()
|
||||
if (el !== undefined) {
|
||||
element.appendChild(el)
|
||||
|
||||
if (elementToAdd !== undefined && !alreadyThere) {
|
||||
element.appendChild(elementToAdd)
|
||||
}
|
||||
|
||||
return this
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue