Restore old values if invalid values for the dropdown was used.

This commit is contained in:
Marc-Andre Ferland 2022-10-30 23:35:42 -04:00
parent d656c34bd4
commit 965efc3a13

View File

@ -17,14 +17,22 @@ const TASK_MAPPING = {
}, },
width: { name: 'Width', width: { name: 'Width',
setUI: (width) => { setUI: (width) => {
const oldVal = widthField.value
widthField.value = width widthField.value = width
if (!widthField.value) {
widthField.value = oldVal
}
}, },
readUI: () => parseInt(widthField.value), readUI: () => parseInt(widthField.value),
parse: (val) => parseInt(val) parse: (val) => parseInt(val)
}, },
height: { name: 'Height', height: { name: 'Height',
setUI: (height) => { setUI: (height) => {
const oldVal = heightField.value
heightField.value = height heightField.value = height
if (!heightField.value) {
heightField.value = oldVal
}
}, },
readUI: () => parseInt(heightField.value), readUI: () => parseInt(heightField.value),
parse: (val) => parseInt(val) parse: (val) => parseInt(val)
@ -103,7 +111,11 @@ const TASK_MAPPING = {
}, },
use_stable_diffusion_model: { name: 'Stable Diffusion model', use_stable_diffusion_model: { name: 'Stable Diffusion model',
setUI: (use_stable_diffusion_model) => { setUI: (use_stable_diffusion_model) => {
const oldVal = stableDiffusionModelField.value
stableDiffusionModelField.value = use_stable_diffusion_model stableDiffusionModelField.value = use_stable_diffusion_model
if (!stableDiffusionModelField.value) {
stableDiffusionModelField.value = oldVal
}
}, },
readUI: () => stableDiffusionModelField.value, readUI: () => stableDiffusionModelField.value,
parse: (val) => val parse: (val) => val