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:
Classic298 2026-09-16 21:44:29 +02:00 • committed by GitHub
parent 48fb2b84ba
commit 556e48e058
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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}