diff --git a/src/components/dropdown/index.module.css b/src/components/dropdown/index.module.css index e49f9eb..3ffce53 100644 --- a/src/components/dropdown/index.module.css +++ b/src/components/dropdown/index.module.css @@ -1,6 +1,5 @@ .box { display: contents; - inline-size: max-content; &:has(> :popover-open) > .button { background-color: var(--surface-500); @@ -15,7 +14,9 @@ grid-template-columns: inherit; place-items: center start; - inline-size: max-content; + /* Make sure the height of the button does not collapse when it is empty */ + block-size: 1em; + box-sizing: content-box; padding: var(--padding-m); background-color: transparent; @@ -44,13 +45,14 @@ .dialog { display: none; + position: relative; grid-template-columns: inherit; inset-inline-start: anchor(start); inset-block-start: anchor(end); - position-try-fallbacks: flip-inline; + position-try-fallbacks: flip-block, flip-inline; - inline-size: anchor-size(self-inline); + /* inline-size: anchor-size(self-inline); */ background-color: var(--surface-500); padding: var(--padding-m); border: none; diff --git a/src/components/dropdown/index.tsx b/src/components/dropdown/index.tsx index 85029b8..e19821c 100644 --- a/src/components/dropdown/index.tsx +++ b/src/components/dropdown/index.tsx @@ -1,12 +1,12 @@ import { createMemo, createSignal, For, JSX, Setter, createEffect, Show } from "solid-js"; -import css from './index.module.css'; import { FaSolidAngleDown } from "solid-icons/fa"; +import css from './index.module.css'; interface DropdownProps { id: string; class?: string; - value: K; - setValue?: Setter; + value?: K; + setValue?: Setter; values: Record; open?: boolean; showCaret?: boolean; @@ -16,7 +16,7 @@ interface DropdownProps { export function Dropdown(props: DropdownProps) { const [dialog, setDialog] = createSignal(); - const [value, setValue] = createSignal(props.value); + const [key, setKey] = createSignal(props.value); const [open, setOpen] = createSignal(props.open ?? false); const [query, setQuery] = createSignal(''); @@ -35,7 +35,7 @@ export function Dropdown(props: DropdownProps) { const showCaret = createMemo(() => props.showCaret ?? true); createEffect(() => { - props.setValue?.(() => value()); + props.setValue?.(() => key()); }); createEffect(() => { @@ -44,7 +44,13 @@ export function Dropdown(props: DropdownProps) { return