Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(site): add preset combobox to dynamic parameters page#19100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,16 +5,10 @@ import { ErrorAlert } from "components/Alert/ErrorAlert";
import { Avatar } from "components/Avatar/Avatar";
import { Badge } from "components/Badge/Badge";
import { Button } from "components/Button/Button";
import { Combobox } from "components/Combobox/Combobox";
import { Input } from "components/Input/Input";
import { Label } from "components/Label/Label";
import { Link } from "components/Link/Link";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "components/Select/Select";
import { Spinner } from "components/Spinner/Spinner";
import { Switch } from "components/Switch/Switch";
import {
Expand DownExpand Up@@ -186,30 +180,31 @@ export const CreateWorkspacePageViewExperimental: FC<
}, [form.submitCount, form.errors]);

const [presetOptions, setPresetOptions] = useState([
{label: "None", value: "None" },
{displayName: "None", value: "undefined", icon: "", description: "" },
]);
const [selectedPresetIndex, setSelectedPresetIndex] = useState(0);
// Build options and keep default label/value in sync
useEffect(() => {
setPresetOptions([
{label: "None", value: "None" },
const options =[
{displayName: "None", value: "undefined", icon: "", description: "" },
...presets.map((preset) => ({
label: preset.Default ? `${preset.Name} (Default)` : preset.Name,
displayName: preset.Default ? `${preset.Name} (Default)` : preset.Name,
value: preset.ID,
icon: preset.Icon,
description: preset.Description,
})),
]);
}, [presets]);

const [selectedPresetIndex, setSelectedPresetIndex] = useState(0);

// Set default preset when presets are loaded
useEffect(() => {
const defaultPreset = presets.find((preset) => preset.Default);
];
setPresetOptions(options);
const defaultPreset = presets.find((p) => p.Default);
if (defaultPreset) {
// +1 because "None" is at index 0
const defaultIndex =
presets.findIndex((preset) => preset.ID === defaultPreset.ID) + 1;
setSelectedPresetIndex(defaultIndex);
const idx = presets.indexOf(defaultPreset) + 1; // +1 for "None"
setSelectedPresetIndex(idx);
form.setFieldValue("template_version_preset_id", defaultPreset.ID);
} else {
setSelectedPresetIndex(0); // Explicitly set to "None"
form.setFieldValue("template_version_preset_id", undefined);
}
}, [presets]);
}, [presets, form.setFieldValue]);

const [presetParameterNames, setPresetParameterNames] = useState<string[]>(
[],
Expand DownExpand Up@@ -572,33 +567,30 @@ export const CreateWorkspacePageViewExperimental: FC<
</div>
<div className="flex flex-col gap-4">
<div className="max-w-lg">
<Select
value={presetOptions[selectedPresetIndex]?.value}
onValueChange={(option) => {
<Combobox
value={
presetOptions[selectedPresetIndex]?.displayName || ""
}
options={presetOptions}
placeholder="Select a preset"
onSelect={(value) => {
const index = presetOptions.findIndex(
(preset) => preset.value ===option,
(preset) => preset.value ===value,
);
if (index === -1) {
return;
}
setSelectedPresetIndex(index);
form.setFieldValue(
"template_version_preset_id",
index === 0 ? undefined : option,
// "undefined" string is equivalent to using None option
// Combobox requires a value in order to correctly highlight the None option
presetOptions[index].value === "undefined"
? undefined
: presetOptions[index].value,
Comment on lines +586 to +590
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

sorry to keep bringing up merged pull requests, but couldn'tvalue just be""? then it wouldn't need this special handling, asundefined gets deserialized the same as"" by the backend

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@aslilac Ideally, yes, it should be an empty string. However, this appears to be an issue with theCombobox component: when no value is provided, the "None" option doesn't get highlighted on hover like the other options do. This was a workaround to ensure consistent hover behavior, including for the "None" option.

@jaaydenh helped me investigate this and came up with the workaround, so he may have more context.

I've included a recording below showing the difference:

  • When value is "": "None" is not highlighted on hover
Screen.Recording.2025-08-04.at.16.09.20.mov
  • When value is set: "None" is highlighted on hover
Screen.Recording.2025-08-04.at.16.10.17.mov

);
}}
>
<SelectTrigger>
<SelectValue placeholder={"Select a preset"} />
</SelectTrigger>
<SelectContent>
{presetOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
/>
</div>
{/* Only show the preset parameter visibility toggle if preset parameters are actually being modified, otherwise it is ineffectual */}
{presetParameterNames.length > 0 && (
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp