mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-03 02:23:51 +00:00
fix: honor false defaults on checkbox prompt variables (#30037)
A prompt template with `{{flag | checkbox:default=false}}` opened the input variables form with the checkbox already ticked, and the same happened for `False`, `"false"`, `0` and `"0"`. Template defaults arrive as strings and the checkbox was bound straight to that value, so any non-empty string counted as checked and there was no way to define a checkbox that starts unchecked once a default was given.
The checkbox now reads its ticked state from the value explicitly: it is checked only for `true` (boolean or string) and stays unchecked for anything else, while clicking it still writes a boolean like before. The seeded value itself is left alone, so what gets substituted into the prompt for an untouched form is unchanged, and typing `true` or `false` into the text field next to the checkbox now moves the tick accordingly.
Fixes #30036
This commit is contained in:
parent
48fb2b84ba
commit
556e48e058
1 changed files with 3 additions and 1 deletions
|
|
@ -140,7 +140,9 @@
|
|||
<div class="relative flex justify-center items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={variableValues[variable]}
|
||||
checked={variableValues[variable] === true ||
|
||||
variableValues[variable] === 'true'}
|
||||
on:change={(e) => (variableValues[variable] = e.target.checked)}
|
||||
class="size-3.5 rounded cursor-pointer border border-gray-200 dark:border-gray-700"
|
||||
id="input-variable-{idx}"
|
||||
{...variableAttributes}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue