mirror of
https://github.com/dzeiocom/FormManager.git
synced 2025-04-22 10:52:16 +00:00
fix Select input not setting the correct value
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
93adf6d225
commit
44762c6e72
@ -10,25 +10,16 @@ import { realType } from '../Functions';
|
||||
export default class SelectInput extends DefaultInput {
|
||||
|
||||
public setValue(value: any) {
|
||||
value = realType(value)
|
||||
let opt:HTMLOptionElement|undefined = this.element.querySelector(`option[value="${value}"]`) || undefined
|
||||
if (opt) {
|
||||
this.element.value = value
|
||||
return
|
||||
}
|
||||
opt = this.element.querySelector("option[selected]") || undefined
|
||||
if (opt) {
|
||||
this.element.value = opt.value
|
||||
}
|
||||
this.element.value = this.formatValue(value)
|
||||
}
|
||||
|
||||
public formatValue(value: any): any {
|
||||
if (typeof value !== "undefined" && value !== "") {
|
||||
return realType(value)
|
||||
}
|
||||
const opt: HTMLOptionElement|undefined = this.element.querySelector("option[selected]") || undefined
|
||||
const opt = this.element.querySelector("option[selected]") || undefined
|
||||
if (opt) {
|
||||
return opt.value
|
||||
return (opt as HTMLOptionElement).value
|
||||
}
|
||||
throw Error(":O it should never come here")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user