mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-02 21:03:34 +03:00
fix(forms): Fix checkbox export values and wide dropdown options (#7288)
Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
This commit is contained in:
co-authored by
Anthony Stirling
parent
8c00fffe18
commit
74be5bf0ad
@@ -68,8 +68,11 @@ function FieldInputInner({
|
|||||||
);
|
);
|
||||||
|
|
||||||
case "checkbox": {
|
case "checkbox": {
|
||||||
const isChecked = !!value && value !== "Off";
|
const exportVal = field.widgets && field.widgets[0]?.exportValue;
|
||||||
const onValue = (field.widgets && field.widgets[0]?.exportValue) || "Yes";
|
const isChecked = exportVal
|
||||||
|
? value === exportVal || value === "Yes"
|
||||||
|
: !!value && value !== "Off";
|
||||||
|
const onValue = exportVal || "Yes";
|
||||||
return (
|
return (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
size="xs"
|
size="xs"
|
||||||
|
|||||||
@@ -338,9 +338,11 @@ function WidgetInputInner({
|
|||||||
);
|
);
|
||||||
|
|
||||||
case "checkbox": {
|
case "checkbox": {
|
||||||
// Checkbox is checked when value is anything other than 'Off' or empty
|
// Checkbox is checked when value matches exportValue if present, or is non-empty and not 'Off'
|
||||||
const isChecked = !!value && value !== "Off";
|
const isChecked = widget.exportValue
|
||||||
// When toggling on, use the widget's exportValue (e.g. 'Red', 'Blue') or fall back to 'Yes'
|
? value === widget.exportValue || value === "Yes"
|
||||||
|
: !!value && value !== "Off";
|
||||||
|
// When toggling on, use the widget's exportValue (e.g. 'Red', 'Blue', 'Pass') or fall back to 'Yes'
|
||||||
const onValue = widget.exportValue || "Yes";
|
const onValue = widget.exportValue || "Yes";
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -433,6 +435,7 @@ function WidgetInputInner({
|
|||||||
multiple={field.multiSelect}
|
multiple={field.multiSelect}
|
||||||
style={{
|
style={{
|
||||||
...inputBaseStyle,
|
...inputBaseStyle,
|
||||||
|
minWidth: "100%",
|
||||||
padding: 0,
|
padding: 0,
|
||||||
paddingLeft: 2,
|
paddingLeft: 2,
|
||||||
appearance: "auto",
|
appearance: "auto",
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ function toFormField(
|
|||||||
// Derive value string
|
// Derive value string
|
||||||
let value = f.value;
|
let value = f.value;
|
||||||
if (type === "checkbox") {
|
if (type === "checkbox") {
|
||||||
value = f.isChecked ? "Yes" : "Off";
|
value = f.isChecked ? f.widgets[0]?.exportValue || "Yes" : "Off";
|
||||||
} else if (type === "radio") {
|
} else if (type === "radio") {
|
||||||
// Use widget index as the canonical radio value.
|
// Use widget index as the canonical radio value.
|
||||||
// This avoids issues with duplicate exportValues across widgets
|
// This avoids issues with duplicate exportValues across widgets
|
||||||
|
|||||||
Reference in New Issue
Block a user