дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
fix(run-targets): apply a published ports edit that hasn't left the field (#6966)
Published ports and the other list fields of a run target were stored only on blur, so OK pressed with Enter, or applying the settings while the field still had focus, dropped the edit. The list is now staged on every change; the text stays as typed while the field has focus.
Цей коміт міститься в:
1 джерело
1c377b7f66
коміт
f80be658ea
2 files changed
+21
-11
No files matched your search
@@ -43,17 +43,26 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("Run Targets detail form", () => {
|
||||
it("does not commit an uncommitted ports edit to the target selected while it is open", () => {
|
||||
it("keeps a ports edit with the target it was made to when another target is selected", () => {
|
||||
mount();
|
||||
// An edit to odoo110's published ports that ListField has not committed yet.
|
||||
// An edit to odoo110's published ports, still focused.
|
||||
fireEvent.change(portsBox(), { target: { value: "8069" } });
|
||||
// Selecting another target switches selection on mousedown, before the blur commits.
|
||||
// Selecting another target switches selection on mousedown, before the field loses focus.
|
||||
fireEvent.mouseDown(screen.getByRole("option", { name: /odoo170/ }));
|
||||
fireEvent.blur(portsBox());
|
||||
// odoo170 keeps its own ports; the uncommitted draft is not written over them.
|
||||
// odoo170 keeps its own ports; the edit is not written over them.
|
||||
expect(portsBox().value).toBe("9000:9000");
|
||||
// And odoo110 still holds what it held before the edit was committed anywhere.
|
||||
// And odoo110 holds the edit.
|
||||
fireEvent.mouseDown(screen.getByRole("option", { name: /odoo110/ }));
|
||||
expect(portsBox().value).toBe("8069:8069");
|
||||
expect(portsBox().value).toBe("8069");
|
||||
});
|
||||
|
||||
it("stages a ports edit before the field loses focus, so OK applies it", () => {
|
||||
mount();
|
||||
fireEvent.change(portsBox(), { target: { value: "8069:8069 8070:8070" } });
|
||||
expect(portsBox().value).toBe("8069:8069 8070:8070");
|
||||
const change = Object.values(useSettingsDialog.getState().staged).find((c) => c.key === "runTargets");
|
||||
const targets = change?.value as Array<{ id: string; ports: string[] }> | undefined;
|
||||
expect(targets?.find((t) => t.id === "odoo110")?.ports).toEqual(["8069:8069", "8070:8070"]);
|
||||
});
|
||||
});
|
||||
@@ -263,7 +263,8 @@ function ListField({
|
||||
hint?: string;
|
||||
}) {
|
||||
const id = useId();
|
||||
// Edited as text; the list is stored once the field loses focus.
|
||||
// Edited as text, which stays as typed while the field has focus; the list is stored on every change, so OK
|
||||
// (Enter included) applies an edit that hasn't left the field.
|
||||
const [draft, setDraft] = useState<string | null>(null);
|
||||
return (
|
||||
<Row label={label} htmlFor={id} className={styles.alignedRow} hint={hint}>
|
||||
@@ -273,11 +274,11 @@ function ListField({
|
||||
className={styles.wide}
|
||||
value={draft ?? value.join(" ")}
|
||||
placeholder={placeholder}
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
onBlur={() => {
|
||||
if (draft !== null) onChange(splitList(draft));
|
||||
setDraft(null);
|
||||
onChange={(e) => {
|
||||
setDraft(e.target.value);
|
||||
onChange(splitList(e.target.value));
|
||||
}}
|
||||
onBlur={() => setDraft(null)}
|
||||
/>
|
||||
</Row>
|
||||
);
|
||||
|
||||
Reference in new issue
Заблокувати користувача