Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/utils/gradient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ export function getSelectedGradient(
return { currentGradient: defaultValue, selectedOption: { value: defaultValue, display_name: defaultValue, path: "" } as GradientOption };
}

// Determine current packing mode and filter options accorrdingly
const modePath = gradientOptions[0].packing_mode_path ?? "";
const rawMode = modePath ? getCurrentValue(modePath) : undefined;
const currentMode = typeof rawMode === "string" ? rawMode : "gradient";
const validOptions =
gradientOptions.filter(o => o.packing_mode === currentMode);

if (!validOptions.length) {
// Fallback to default if no valid options
return { currentGradient: defaultValue, selectedOption: { value: defaultValue, display_name: defaultValue, path: "" } as GradientOption };
}

// Shared selector path (all options for this control share it)
const selectorPath = gradientOptions[0].path ?? "";

Expand All @@ -48,9 +60,9 @@ export function getSelectedGradient(

// The full option object for that value, or first as fallback
const selectedOption =
gradientOptions.find(o => o.value === currentGradient) ?? gradientOptions[0];
validOptions.find(o => o.value === currentGradient) ?? validOptions[0];

return { currentGradient, selectedOption };
return { currentGradient: selectedOption.value, selectedOption };
}


Expand Down