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
 | 
					            throw "SEVERE: could not attach UIElement to " + divId
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while (element.firstChild) {
 | 
					        let alreadyThere = false
 | 
				
			||||||
            //The list is LIVE so it will re-index each call
 | 
					        const elementToAdd = this.ConstructElement()
 | 
				
			||||||
            element.removeChild(element.firstChild)
 | 
					        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) {
 | 
					        if (elementToAdd !== undefined && !alreadyThere) {
 | 
				
			||||||
            element.appendChild(el)
 | 
					            element.appendChild(elementToAdd)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return this
 | 
					        return this
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue