From b73de90487ba2d89346877e919d7335806c98027 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Thu, 9 Jan 2025 10:15:29 +0100 Subject: [PATCH] Fix: select add portalRef instead of modalContextId --- .../webview-ui/app/src/Form/fields/Select.tsx | 12 +- .../src/routes/machines/install/disk-step.tsx | 134 ++++++++++-------- 2 files changed, 84 insertions(+), 62 deletions(-) diff --git a/pkgs/webview-ui/app/src/Form/fields/Select.tsx b/pkgs/webview-ui/app/src/Form/fields/Select.tsx index 18a98534b..8a149e9b3 100644 --- a/pkgs/webview-ui/app/src/Form/fields/Select.tsx +++ b/pkgs/webview-ui/app/src/Form/fields/Select.tsx @@ -5,6 +5,7 @@ import { type JSX, For, createMemo, + Accessor, } from "solid-js"; import { Portal } from "solid-js/web"; import { useFloating } from "../base"; @@ -46,11 +47,12 @@ interface SelectInputpProps { placeholder?: string; multiple?: boolean; loading?: boolean; - dialogContextId?: string; + portalRef?: Accessor; } export function SelectInput(props: SelectInputpProps) { - const dialogContext = useContext(props.dialogContextId); + const dialogContext = (dialogContextId?: string) => + useContext(dialogContextId); const _id = createUniqueId(); @@ -228,7 +230,11 @@ export function SelectInput(props: SelectInputpProps) { } /> - +
) => { }, })); + const modalContext = useContext(); + return ( -
- - - {(field, fieldProps) => ( - <> - + +
+
+ + - {(field.value || "No schema selected").split("-").join(" ")} - - ( + <> + + {(field.value || "No schema selected") + .split("-") + .join(" ")} + + + Change schema + + + )} + + + + {props.initial?.initialized && + "Disk has been initialized already"} + - Change schema - - - )} - - - - {props.initial?.initialized && "Disk has been initialized already"} - - {(field, fieldProps) => ( - ({ label: o, value: o })) || [ - { label: "No options", value: "" }, - ] - } - error={field.error} - label="Main Disk" - value={field.value || ""} - placeholder="Select a disk" - selectProps={fieldProps} - required={!props.initial?.initialized} - /> - )} - - - {props.footer} - + {(field, fieldProps) => ( + ({ label: o, value: o })) || [ + { label: "No options", value: "" }, + ] + } + error={field.error} + label="Main Disk" + value={field.value || ""} + placeholder="Select a disk" + selectProps={fieldProps} + required={!props.initial?.initialized} + portalRef={modalContext.contentRef} + /> + )} + + +
+
+ {props.footer} + + ); };