Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

style/fix(properties): lots of property/dropdown fixes (#3442)

Seamus923062e82035
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
index 688fda9aab..beb7a21ed1 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
@@ -1,3 +1,4 @@
+import { useMaybeBlockId } from '@core/block';
import { usePropertiesContext } from '@core/component/Properties/context/PropertiesContext';
import { getEntityValues, hasValue } from '@core/component/Properties/utils';
import CircleDashedEmpty from '@phosphor/circle-dashed.svg';
@@ -18,6 +19,7 @@ type ListPropertyValueProps = {
*/
export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
const ctx = usePropertiesContext();
+ const blockId = useMaybeBlockId();
const isUserEntity = () =>
props.property.valueType === 'ENTITY' &&
@@ -32,7 +34,8 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
<Property.Root
property={props.property}
canEdit={ctx.canEdit}
- onEdit={ctx.openPropertyEditor}
+ onSave={ctx.saveHandler.saveProperty}
+ onRefresh={ctx.onRefresh}
>
<Property.Tooltip property={props.property}>
<Layer depth={2}>
@@ -84,6 +87,9 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
</Property.EditTrigger>
</Layer>
</Property.Tooltip>
+ <Property.PopoverEditor
+ entitySelfFilter={{ entityType: ctx.entityType, blockId }}
+ />
</Property.Root>
);
};
diff --git a/js/app/packages/block-channel/component/Compose.tsx b/js/app/packages/block-channel/component/Compose.tsx
index 74fb2b5cde..db6f6038db 100644
--- a/js/app/packages/block-channel/component/Compose.tsx
+++ b/js/app/packages/block-channel/component/Compose.tsx
@@ -269,7 +269,7 @@ export function ChannelCompose() {
>
<Surface
depth={2}
- class="rounded-xl ring-1 ring-ink-muted/8"
+ class="rounded-xl ring-1 ring-edge"
style={{ border: '0' }}
>
<Input.DropZone
diff --git a/js/app/packages/block-md/component/InlinePropertyValue.tsx b/js/app/packages/block-md/component/InlinePropertyValue.tsx
index 4653817f9b..127f1804c8 100644
--- a/js/app/packages/block-md/component/InlinePropertyValue.tsx
+++ b/js/app/packages/block-md/component/InlinePropertyValue.tsx
@@ -1,3 +1,4 @@
+import { useMaybeBlockId } from '@core/block';
import { usePropertiesContext } from '@core/component/Properties/context/PropertiesContext';
import { getEntityValues, hasValue } from '@core/component/Properties/utils';
import { Property } from '@property';
@@ -20,6 +21,7 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
props
) => {
const ctx = usePropertiesContext();
+ const blockId = useMaybeBlockId();
const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
const isEmpty = () => !hasValue(props.property);
@@ -35,7 +37,8 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
<Property.Root
property={props.property}
canEdit={ctx.canEdit}
- onEdit={ctx.openPropertyEditor}
+ onSave={ctx.saveHandler.saveProperty}
+ onRefresh={ctx.onRefresh}
>
<Property.Tooltip property={props.property}>
<Layer depth={2}>
@@ -73,6 +76,9 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
</Property.EditTrigger>
</Layer>
</Property.Tooltip>
+ <Property.PopoverEditor
+ entitySelfFilter={{ entityType: ctx.entityType, blockId }}
+ />
</Property.Root>
);
};
diff --git a/js/app/packages/channel/Input/ChannelInput.tsx b/js/app/packages/channel/Input/ChannelInput.tsx
index 6406ce7548..3f66a5f478 100644
--- a/js/app/packages/channel/Input/ChannelInput.tsx
+++ b/js/app/packages/channel/Input/ChannelInput.tsx
@@ -183,7 +183,7 @@ export function ChannelInput(props: ChannelInputProps) {
<Input.Root input={inputState.view()} commands={inputState.commands}>
<Surface
depth={2}
- class="rounded-xl ring-1 ring-ink-muted/8"
+ class="rounded-xl ring-1 ring-edge"
style={{ border: '0' }}
>
<Input.DropZone
diff --git a/js/app/packages/core/component/AI/component/input/ChatInput.tsx b/js/app/packages/core/component/AI/component/input/ChatInput.tsx
index 93e118d3c0..75d65c531b 100644
--- a/js/app/packages/core/component/AI/component/input/ChatInput.tsx
+++ b/js/app/packages/core/component/AI/component/input/ChatInput.tsx
@@ -184,7 +184,7 @@ export function ChatInput(props: ChatInputComponentProps) {
return (
<Surface
depth={2}
- class="rounded-xl ring-1 ring-ink-muted/8"
+ class="rounded-xl ring-1 ring-edge"
style={{ border: '0' }}
>
<div id="chat-input" ref={containerRef} class="relative flex flex-col">
diff --git a/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsx b/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsx
index 29c7ba7c5d..6ef3d2b713 100644
--- a/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/CreatePropertyModal.tsx
@@ -1,17 +1,19 @@
import { useBlockId } from '@core/block';
import { useUserId } from '@core/context/user';
+import CaretDownIcon from '@phosphor/caret-down.svg';
+import CheckIcon from '@phosphor/check.svg';
import LoadingSpinner from '@phosphor/spinner.svg';
import XIcon from '@phosphor/x.svg';
-import { Dropdown, type DropdownOption } from '@property';
import { useCreatePropertyDefinitionMutation } from '@queries/properties/definitions';
import { useAddEntityPropertyMutation } from '@queries/properties/entity';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
import type { PropertyDataType } from '@service-properties/generated/schemas/propertyDataType';
-import { Button, Dialog, SegmentedControl, Surface } from '@ui';
+import { Button, Dialog, Dropdown, SegmentedControl, Surface } from '@ui';
import {
type Component,
createMemo,
createSignal,
+ For,
Index,
Show,
} from 'solid-js';
@@ -219,8 +221,14 @@ export const CreatePropertyModal: Component<CreatePropertyModalProps> = (
const userId = useUserId();
- const dataTypeDropdownOptions: DropdownOption<DataTypeValue>[] =
- getPropertyDataTypeDropdownOptions();
+ const dataTypeDropdownOptions = getPropertyDataTypeDropdownOptions();
+
+ const selectedDataTypeLabel = createMemo(() => {
+ const option = dataTypeDropdownOptions.find(
+ (opt) => opt.value === selectedDataType()
+ );
+ return option?.label ?? 'Select type';
+ });
// Helper to parse selected value back to type and specificType
const parseDataTypeValue = (
@@ -454,17 +462,36 @@ export const CreatePropertyModal: Component<CreatePropertyModalProps> = (
<label class="block text-xs font-medium text-ink mb-1">
Data Type
</label>
- <Dropdown
- value={selectedDataType()}
- options={dataTypeDropdownOptions}
- onChange={(value) => {
- setSelectedDataType(value);
- setNewStringOptions([]);
- setNewNumberOptions([]);
- setIsMultiSelect(false);
- }}
- placeholder="Select type"
- />
+ <Dropdown gutter={4}>
+ <Dropdown.Trigger class="w-full p-1.5 border border-edge-muted bg-surface text-sm text-ink text-left flex items-center gap-2 hover:bg-hover rounded-sm justify-between">
+ <span class="truncate">{selectedDataTypeLabel()}</span>
+ <CaretDownIcon class="size-3 text-ink-muted shrink-0" />
+ </Dropdown.Trigger>
+ <Dropdown.Portal>
+ <Dropdown.Content class="max-h-64 overflow-y-auto min-w-48">
+ <For each={dataTypeDropdownOptions}>
+ {(option) => (
+ <Dropdown.Item
+ class="flex items-center justify-between gap-2 px-2 py-1.5 text-sm cursor-pointer"
+ onSelect={() => {
+ setSelectedDataType(option.value);
+ setNewStringOptions([]);
+ setNewNumberOptions([]);
+ setIsMultiSelect(false);
+ }}
+ >
+ <Dropdown.ItemLabel>
+ {option.label}
+ </Dropdown.ItemLabel>
+ <Show when={option.value === selectedDataType()}>
+ <CheckIcon class="size-3 shrink-0" />
+ </Show>
+ </Dropdown.Item>
+ )}
+ </For>
+ </Dropdown.Content>
+ </Dropdown.Portal>
+ </Dropdown>
</div>
<Show when={shouldShowMultiSelect()}>
diff --git a/js/app/packages/core/component/Properties/component/modal/EditPropertyValueModal.tsx b/js/app/packages/core/component/Properties/component/modal/EditPropertyValueModal.tsx
deleted file mode 100644
index df16ba184b..0000000000
--- a/js/app/packages/core/component/Properties/component/modal/EditPropertyValueModal.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import { useMaybeBlockId } from '@core/block';
-import { Property, type PropertyApiValues, useProperty } from '@property';
-import { createEffect, onMount } from 'solid-js';
-import { usePropertiesContext } from '../../context/PropertiesContext';
-import type { PropertyEditorProps } from '../../types';
-
-/**
- * Bridge from the legacy PropertiesContext modal stack to the new
- * @property primitives. Mounts <Property.Root> with the saved property,
- * forwards saves through PropertiesContext's saveHandler, and auto-opens the
- * popover editor against the click anchor. When the local editor closes
- * (ESC / click-out / save-on-close), notifies the legacy stack to clear its
- * modal state.
- *
- * Inline-edit-only types (STRING / NUMBER / BOOLEAN / LINK) never route here
- * — they edit in place. This bridge therefore only renders the popover
- * editors (DATE / SELECT_* / ENTITY).
- */
-export function EditPropertyValueModal(props: PropertyEditorProps) {
- const { saveHandler, entityType } = usePropertiesContext();
- const blockId = useMaybeBlockId();
-
- const onSave = (
- p: Parameters<typeof saveHandler.saveProperty>[0],
- v: PropertyApiValues
- ) => saveHandler.saveProperty(p, v);
-
- return (
- <Property.Root
- property={props.property}
- canEdit
- onSave={onSave}
- onRefresh={props.onSaved}
- >
- <LegacyEditorBridge anchor={props.anchorRef} onExit={props.onClose} />
- <Property.PopoverEditor entitySelfFilter={{ entityType, blockId }} />
- </Property.Root>
- );
-}
-
-function LegacyEditorBridge(props: {
- anchor?: HTMLElement;
- onExit: () => void;
-}) {
- const ctx = useProperty();
- let hasOpened = false;
-
- onMount(() => {
- ctx.openEditor(props.anchor);
- });
-
- createEffect(() => {
- if (ctx.editorOpen()) {
- hasOpened = true;
- } else if (hasOpened) {
- props.onExit();
- }
- });
-
- return null;
-}
diff --git a/js/app/packages/core/component/Properties/component/modal/Modals.tsx b/js/app/packages/core/component/Properties/component/modal/Modals.tsx
index 1074c28515..45cad19755 100644
--- a/js/app/packages/core/component/Properties/component/modal/Modals.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/Modals.tsx
@@ -7,20 +7,15 @@ import {
import { Show } from 'solid-js/web';
import { usePropertiesContext } from '../../context/PropertiesContext';
import { CreatePropertyModal } from './CreatePropertyModal';
-import { EditPropertyValueModal } from './EditPropertyValueModal';
import { SelectPropertyModal } from './SelectPropertyModal';
export const Modals: Component = () => {
const {
- entityType,
onPropertyAdded,
properties,
- onRefresh,
propertySelectorModal,
- propertyEditorModal,
createPropertyModal,
closePropertySelector,
- closePropertyEditor,
closeCreateProperty,
onPropertyPinned,
} = usePropertiesContext();
@@ -48,11 +43,6 @@ export const Modals: Component = () => {
return properties().map((prop) => prop.propertyDefinitionId);
});
- const handlePropertySaved = () => {
- onRefresh();
- closePropertyEditor();
- };
-
const handlePropertyCreated = (propertyDefinitionId?: string) => {
if (propertyDefinitionId) {
onPropertyAdded([propertyDefinitionId]);
@@ -73,18 +63,6 @@ export const Modals: Component = () => {
/>
</Show>
- <Show when={propertyEditorModal()}>
- {(state) => (
- <EditPropertyValueModal
- property={state().property}
- onClose={closePropertyEditor}
- onSaved={handlePropertySaved}
- anchorRef={state().anchor ?? undefined}
- entityType={entityType}
- />
- )}
- </Show>
-
<Show when={createPropertyModal()}>
{(state) => (
<CreatePropertyModal
diff --git a/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsx b/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsx
index 7dc012ffd9..37ab9b7d11 100644
--- a/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/SelectPropertyModal.tsx
@@ -1,4 +1,5 @@
import { useBlockId } from '@core/block';
+import { ENABLE_CREATE_PROPERTY } from '@core/constant/featureFlags';
import { useListKeyBindings } from '@core/util/useListKeyBindings';
import PlusIcon from '@phosphor/plus.svg';
import LoadingSpinner from '@phosphor/spinner.svg';
@@ -82,6 +83,8 @@ export function SelectPropertyModal(props: PropertySelectorProps) {
const createIndex = createMemo(() => filteredProperties().length);
+ const canCreateProperty = ENABLE_CREATE_PROPERTY;
+
const addProperty = async (propertyDefinitionId: string) => {
try {
await addMutation.mutateAsync({
@@ -130,16 +133,22 @@ export function SelectPropertyModal(props: PropertySelectorProps) {
createEffect(() => {
const items = filteredProperties();
- const totalLen = items.length + 1; // +1 for Create row
+ const totalLen = canCreateProperty ? items.length + 1 : items.length; // +1 for Create row if enabled
+ const noop = () => setFocusedIndex(0);
setKeybindings({
- next: () => setFocusedIndex((prev) => (prev + 1) % totalLen),
- previous: () =>
- setFocusedIndex((prev) => (prev - 1 + totalLen) % totalLen),
+ next:
+ totalLen === 0
+ ? noop
+ : () => setFocusedIndex((prev) => (prev + 1) % totalLen),
+ previous:
+ totalLen === 0
+ ? noop
+ : () => setFocusedIndex((prev) => (prev - 1 + totalLen) % totalLen),
select: () => {
const idx = focusedIndex();
- if (idx >= items.length) {
+ if (canCreateProperty && idx >= items.length) {
handleCreate();
- } else {
+ } else if (idx < items.length) {
addProperty(items[idx].id);
}
},
@@ -213,21 +222,23 @@ export function SelectPropertyModal(props: PropertySelectorProps) {
</button>
)}
</For>
- <button
- type="button"
- id={`select-property-option-${createIndex()}`}
- class={cn(
- 'flex flex-row w-full items-center gap-2 py-1.5 px-2 scroll-my-1',
- isFocused(createIndex()) && 'bg-hover'
- )}
- onClick={handleCreate}
- onMouseEnter={() => setFocusedIndex(createIndex())}
- >
- <PlusIcon class="size-4 shrink-0" />
- <p class="text-sm font-medium truncate flex-1 text-left">
- {createLabel()}
- </p>
- </button>
+ <Show when={canCreateProperty}>
+ <button
+ type="button"
+ id={`select-property-option-${createIndex()}`}
+ class={cn(
+ 'flex flex-row w-full items-center gap-2 py-1.5 px-2 scroll-my-1',
+ isFocused(createIndex()) && 'bg-hover'
+ )}
+ onClick={handleCreate}
+ onMouseEnter={() => setFocusedIndex(createIndex())}
+ >
+ <PlusIcon class="size-4 shrink-0" />
+ <p class="text-sm font-medium truncate flex-1 text-left">
+ {createLabel()}
+ </p>
+ </button>
+ </Show>
</div>
</Show>
</div>
diff --git a/js/app/packages/core/component/Properties/context/PropertiesContext.tsx b/js/app/packages/core/component/Properties/context/PropertiesContext.tsx
index cca2278a94..3069322b35 100644
--- a/js/app/packages/core/component/Properties/context/PropertiesContext.tsx
+++ b/js/app/packages/core/component/Properties/context/PropertiesContext.tsx
@@ -15,11 +15,6 @@ interface PropertySelectorModalState {
isOpen: boolean;
}
-interface PropertyEditorModalState {
- property: Property;
- anchor?: HTMLElement;
-}
-
interface DatePickerModalState {
property: Property & { valueType: 'DATE' };
anchor?: HTMLElement;
@@ -50,7 +45,6 @@ interface PropertiesContextValue {
// Specific modal state accessors
propertySelectorModal: Accessor<PropertySelectorModalState | null>;
- propertyEditorModal: Accessor<PropertyEditorModalState | null>;
datePickerModal: Accessor<DatePickerModalState | null>;
createPropertyModal: Accessor<CreatePropertyModalState | null>;
@@ -58,9 +52,6 @@ interface PropertiesContextValue {
openPropertySelector: () => void;
closePropertySelector: () => void;
- openPropertyEditor: (property: Property, anchor?: HTMLElement) => void;
- closePropertyEditor: () => void;
-
openDatePicker: (
property: Property & { valueType: 'DATE' },
anchor?: HTMLElement
@@ -94,8 +85,6 @@ export function PropertiesProvider(props: PropertiesProviderProps) {
// Modal state signals
const [propertySelectorModal, setPropertySelectorModal] =
createSignal<PropertySelectorModalState | null>(null);
- const [propertyEditorModal, setPropertyEditorModal] =
- createSignal<PropertyEditorModalState | null>(null);
const [datePickerModal, setDatePickerModal] =
createSignal<DatePickerModalState | null>(null);
const [createPropertyModal, setCreatePropertyModal] =
@@ -110,15 +99,6 @@ export function PropertiesProvider(props: PropertiesProviderProps) {
setPropertySelectorModal(null);
};
- // Property Editor actions
- const openPropertyEditor = (property: Property, anchor?: HTMLElement) => {
- setPropertyEditorModal({ property, anchor });
- };
-
- const closePropertyEditor = () => {
- setPropertyEditorModal(null);
- };
-
// Date Picker actions
const openDatePicker = (
property: Property & { valueType: 'DATE' },
@@ -143,7 +123,6 @@ export function PropertiesProvider(props: PropertiesProviderProps) {
// Convenience function to close all modals
const closeAllModals = () => {
setPropertySelectorModal(null);
- setPropertyEditorModal(null);
setDatePickerModal(null);
setCreatePropertyModal(null);
};
@@ -153,7 +132,6 @@ export function PropertiesProvider(props: PropertiesProviderProps) {
createEffect(() => {
const isAnyModalOpen =
propertySelectorModal() !== null ||
- propertyEditorModal() !== null ||
datePickerModal() !== null ||
createPropertyModal() !== null;
@@ -191,14 +169,11 @@ export function PropertiesProvider(props: PropertiesProviderProps) {
saveHandler: props.saveHandler,
// Specific modal state
propertySelectorModal,
- propertyEditorModal,
datePickerModal,
createPropertyModal,
// Specific modal actions
openPropertySelector,
closePropertySelector,
- openPropertyEditor,
- closePropertyEditor,
openDatePicker,
closeDatePicker,
openCreateProperty,
diff --git a/js/app/packages/core/component/Properties/types.ts b/js/app/packages/core/component/Properties/types.ts
index ab311ff11f..ac8959d6d7 100644
--- a/js/app/packages/core/component/Properties/types.ts
+++ b/js/app/packages/core/component/Properties/types.ts
@@ -136,14 +136,6 @@ export type PropertiesPanelProps = {
onRefresh?: () => void;
};
-export type PropertyEditorProps = {
- property: Property;
- onClose: () => void;
- onSaved: () => void;
- anchorRef?: HTMLElement;
- entityType: EntityType;
-};
-
export type PropertySelectorProps = {
isOpen: boolean;
onClose: () => void;
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index e3cb63e7b8..eebda2837a 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -353,3 +353,13 @@ export const ENABLE_MARKDOWN_SIDE_PANEL = resolveFeatureFlag(
'ENABLE_MARKDOWN_SIDE_PANEL',
true
);
+
+export const ENABLE_REFOCUS_HIGHLIGHT = resolveFeatureFlag(
+ 'ENABLE_REFOCUS_HIGHLIGHT',
+ true
+);
+
+export const ENABLE_CREATE_PROPERTY = resolveFeatureFlag(
+ 'ENABLE_CREATE_PROPERTY',
+ false
+);
diff --git a/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
index d8c3ecf8d8..4bf1a230ef 100644
--- a/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
+++ b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
@@ -1,3 +1,4 @@
+import { useMaybeBlockId } from '@core/block';
import { Modals } from '@core/component/Properties/component/modal';
import {
PropertiesProvider,
@@ -59,9 +60,9 @@ interface EntityKeyPropertiesProps {
/**
* Displays key properties (Status, Priority, Assignees) for an entity as a
- * row of condensed icon-only pills. Click routes through the legacy modal
- * stack via `openPropertyEditor` so the existing PropertyEditModal (now
- * itself a thin bridge over Property.PopoverEditor) handles editing.
+ * row of condensed icon-only pills. Each pill owns its own Kobalte-backed
+ * popover editor via <Property.PopoverEditor /> rendered inline below the
+ * trigger — no modal stack involved.
*/
export function EntityKeyProperties(props: EntityKeyPropertiesProps) {
const entityType = createMemo(() => getEntityType(props.entity));
@@ -121,6 +122,7 @@ function KeyPropertiesRow(props: {
onRefresh?: () => void;
}) {
const ctx = usePropertiesContext();
+ const blockId = useMaybeBlockId();
return (
<div class="flex items-center gap-1 justify-start text-xs">
@@ -139,7 +141,8 @@ function KeyPropertiesRow(props: {
<Property.Root
property={property}
canEdit={ctx.canEdit}
- onEdit={ctx.openPropertyEditor}
+ onSave={ctx.saveHandler.saveProperty}
+ onRefresh={ctx.onRefresh}
>
<Property.Tooltip property={property}>
<Layer depth={2}>
@@ -179,6 +182,9 @@ function KeyPropertiesRow(props: {
</Property.EditTrigger>
</Layer>
</Property.Tooltip>
+ <Property.PopoverEditor
+ entitySelfFilter={{ entityType: ctx.entityType, blockId }}
+ />
</Property.Root>
);
}}
diff --git a/js/app/packages/property/src/core/Root.tsx b/js/app/packages/property/src/core/Root.tsx
index 64ecd1c331..a42612974b 100644
--- a/js/app/packages/property/src/core/Root.tsx
+++ b/js/app/packages/property/src/core/Root.tsx
@@ -1,5 +1,5 @@
-import { cn } from '@ui';
-import { createSignal, type JSX, splitProps } from 'solid-js';
+import { cn, Dropdown } from '@ui';
+import { createSignal, type JSX, onMount, splitProps } from 'solid-js';
import type { Property } from '../types';
import {
type PropertyEditFn,
@@ -32,6 +32,13 @@ export function Root(props: PropertyRootProps) {
const [editorAnchor, setEditorAnchor] = createSignal<HTMLElement | undefined>(
undefined
);
+ const [portalMount, setPortalMount] = createSignal<HTMLElement | undefined>();
+
+ let rootEl!: HTMLDivElement;
+ onMount(() => {
+ const scoped = rootEl.closest<HTMLElement>('.portal-scope');
+ if (scoped) setPortalMount(scoped);
+ });
const value: PropertyRootContextValue = {
property: () => local.property,
@@ -46,28 +53,36 @@ export function Root(props: PropertyRootProps) {
return local.onRefresh;
},
editorOpen,
- editorAnchor,
openEditor: (anchor) => {
- setEditorAnchor(() => anchor);
+ if (anchor) setEditorAnchor(() => anchor);
setEditorOpen(true);
},
closeEditor: () => {
setEditorOpen(false);
- setEditorAnchor(() => undefined);
},
+ portalMount,
};
return (
<PropertyRootContext.Provider value={value}>
- <div
- class={cn('property-root', local.class)}
- data-property
- data-property-id={local.property.propertyId}
- data-property-type={local.property.valueType}
- {...rest}
+ <Dropdown
+ open={editorOpen()}
+ onOpenChange={setEditorOpen}
+ getAnchorRect={() => editorAnchor()?.getBoundingClientRect()}
+ gutter={4}
+ placement="bottom-start"
>
- {local.children}
- </div>
+ <div
+ ref={rootEl}
+ class={cn('property-root', local.class)}
+ data-property
+ data-property-id={local.property.propertyId}
+ data-property-type={local.property.valueType}
+ {...rest}
+ >
+ {local.children}
+ </div>
+ </Dropdown>
</PropertyRootContext.Provider>
);
}
diff --git a/js/app/packages/property/src/core/context.ts b/js/app/packages/property/src/core/context.ts
index fd0ec53b60..9c56441315 100644
--- a/js/app/packages/property/src/core/context.ts
+++ b/js/app/packages/property/src/core/context.ts
@@ -15,13 +15,20 @@ export interface PropertyRootContextValue {
onEdit?: PropertyEditFn;
onRefresh?: () => void;
- // Local editor open state. Populated by EditTrigger when the consumer
- // hasn't supplied an external onEdit; consumed by PopoverEditor. Always
- // present (signals never undefined) so consumers can read without nulls.
+ // Local editor open state. Populated by EditTrigger when the consumer hasn't
+ // supplied an external onEdit; consumed by PopoverEditor. The anchor passed
+ // to openEditor is recorded internally by <Property.Root> and used by the
+ // Kobalte popper via getAnchorRect — callers don't read it back.
editorOpen: Accessor<boolean>;
- editorAnchor: Accessor<HTMLElement | undefined>;
openEditor: (anchor?: HTMLElement) => void;
closeEditor: () => void;
+
+ // Closest `.portal-scope` ancestor at the time Property.Root mounted.
+ // Used by PopoverEditor to mount the dropdown into the same stacking
+ // context as the surrounding panel/dialog instead of document.body —
+ // otherwise the editor renders behind a host modal. Undefined until the
+ // root div mounts, after which Kobalte's Portal falls back to body.
+ portalMount: Accessor<HTMLElement | undefined>;
}
export const PropertyRootContext = createContext<PropertyRootContextValue>();
@@ -33,7 +40,3 @@ export function useProperty(): PropertyRootContextValue {
}
return ctx;
}
-
-function _useMaybeProperty(): PropertyRootContextValue | undefined {
- return useContext(PropertyRootContext);
-}
diff --git a/js/app/packages/property/src/editors/popover/EditorPopover.tsx b/js/app/packages/property/src/editors/popover/EditorPopover.tsx
index 6b408c1b39..6c65f074d7 100644
--- a/js/app/packages/property/src/editors/popover/EditorPopover.tsx
+++ b/js/app/packages/property/src/editors/popover/EditorPopover.tsx
@@ -1,92 +1,48 @@
-import { floatWithElement } from '@core/component/LexicalMarkdown/directive/floatWithElement';
-import { ScopedPortal } from '@core/component/ScopedPortal';
-import { cn, Layer } from '@ui';
-import { type JSX, onCleanup, onMount, Show } from 'solid-js';
+import { cn, Dropdown, Layer } from '@ui';
+import type { JSX } from 'solid-js';
import { useProperty } from '../../core/context';
type EditorPopoverProps = {
children: JSX.Element;
class?: string;
/**
- * Called on ESC or click outside. Default: <Property.Root>'s closeEditor.
+ * Called on ESC or outside-interaction. Default: <Property.Root>'s closeEditor.
* Override to save-on-close.
*/
onClose?: () => void;
};
/**
- * Floating shell for popover-style editors (date / select / entity). Mounts
- * only when the parent <Property.Root>'s editor is open; floats with
- * `editorAnchor`; routes ESC + click-outside through onClose (defaults to
- * closeEditor so consumers without a save-on-close opt out get the legacy
- * behavior for free).
+ * Floating shell for popover-style editors (date / select / entity). The
+ * surrounding <Property.Root> hosts a Kobalte DropdownMenu — this component
+ * just renders the Portal/Content. Kobalte handles ESC, click-outside, focus
+ * trap, and focus return. `onClose` is invoked on dismissal so consumers can
+ * save-on-close.
*/
export function EditorPopover(props: EditorPopoverProps) {
const ctx = useProperty();
- return (
- <Show when={ctx.editorOpen()}>
- <PopoverBody onClose={props.onClose} class={props.class}>
- {props.children}
- </PopoverBody>
- </Show>
- );
-}
-
-function PopoverBody(props: {
- children: JSX.Element;
- class?: string;
- onClose?: () => void;
-}) {
- const ctx = useProperty();
-
const close = () => {
if (props.onClose) props.onClose();
else ctx.closeEditor();
};
- const handleKeyDown = (e: KeyboardEvent) => {
- if (e.key === 'Escape') {
- e.preventDefault();
- e.stopPropagation();
- close();
- }
- };
-
- onMount(() => {
- document.addEventListener('keydown', handleKeyDown, { capture: true });
- });
- onCleanup(() => {
- document.removeEventListener('keydown', handleKeyDown, { capture: true });
- });
-
return (
- <ScopedPortal scope="local">
- <div
- class="fixed inset-0 z-modal"
- onClick={(e) => {
- e.stopPropagation();
- close();
- }}
- >
- <Layer depth={2}>
- <div
- ref={(ref) =>
- floatWithElement(ref, () => ({
- element: () => ctx.editorAnchor() ?? null,
- }))
- }
- class={cn(
- 'absolute border border-edge rounded-md z-action-menu max-h-96 overflow-hidden flex flex-col w-full max-w-60 shadow-md shadow-drop-shadow bg-surface text-ink',
- props.class
- )}
- tabIndex={-1}
- onClick={(e) => e.stopPropagation()}
- >
- {props.children}
- </div>
- </Layer>
- </div>
- </ScopedPortal>
+ <Dropdown.Portal mount={ctx.portalMount()}>
+ {/* manual pointer block for this. */}
+ <div class="fixed inset-0 z-action-menu" onClick={close} />
+ <Layer depth={3}>
+ <Dropdown.Content
+ class={cn(
+ 'max-h-96 overflow-hidden flex flex-col w-full max-w-60 p-0',
+ props.class
+ )}
+ onEscapeKeyDown={close}
+ onInteractOutside={close}
+ >
+ {props.children}
+ </Dropdown.Content>
+ </Layer>
+ </Dropdown.Portal>
);
}
diff --git a/js/app/packages/property/src/editors/selectors/Dropdown.tsx b/js/app/packages/property/src/editors/selectors/Dropdown.tsx
deleted file mode 100644
index a9358372c9..0000000000
--- a/js/app/packages/property/src/editors/selectors/Dropdown.tsx
+++ /dev/null
@@ -1,170 +0,0 @@
-import { ScopedPortal } from '@core/component/ScopedPortal';
-import ChevronDownIcon from '@phosphor/caret-down.svg';
-import CheckIcon from '@phosphor/check.svg';
-import { cn, Layer } from '@ui';
-import {
- type Component,
- createEffect,
- createSignal,
- For,
- type JSXElement,
- onCleanup,
- Show,
-} from 'solid-js';
-
-export type DropdownOption<T> = {
- value: T;
- label: string;
- icon?: JSXElement;
- description?: string;
- disabled?: boolean;
-};
-
-type DropdownProps<T> = {
- value: T;
- options: Array<DropdownOption<T>>;
- onChange: (value: T) => void;
- placeholder?: string;
- class?: string;
- /** Optional custom renderer for dropdown items */
- renderOption?: (option: DropdownOption<T>, isSelected: boolean) => JSXElement;
- /** Optional custom renderer for the selected value display */
- renderValue?: (option: DropdownOption<T> | undefined) => JSXElement;
-};
-
-export const Dropdown = <T extends string | number>(
- props: DropdownProps<T>
-): ReturnType<Component> => {
- const [isOpen, setIsOpen] = createSignal(false);
- let dropdownRef!: HTMLDivElement;
- let buttonRef!: HTMLButtonElement;
- let menuRef!: HTMLDivElement;
-
- // Close dropdown when clicking outside
- createEffect(() => {
- if (!isOpen()) return;
-
- const handleClickOutside = (e: MouseEvent) => {
- const target = e.target as Node;
- if (
- dropdownRef &&
- !dropdownRef.contains(target) &&
- menuRef &&
- !menuRef.contains(target)
- ) {
- setIsOpen(false);
- }
- };
-
- document.addEventListener('mousedown', handleClickOutside);
- onCleanup(() =>
- document.removeEventListener('mousedown', handleClickOutside)
- );
- });
-
- const selectedOption = () =>
- props.options.find((opt) => opt.value === props.value);
-
- const getMenuStyle = () => {
- if (!buttonRef) return {};
- const rect = buttonRef.getBoundingClientRect();
- return {
- position: 'fixed' as const,
- top: `${rect.bottom + 4}px`,
- left: `${rect.left}px`,
- width: `${rect.width}px`,
- };
- };
-
- const defaultRenderValue = (option: DropdownOption<T> | undefined) => (
- <>
- <Show when={option?.icon}>
- <span class="shrink-0">{option!.icon}</span>
- </Show>
- <span class="flex-1 truncate">
- {option?.label ?? props.placeholder ?? 'Select...'}
- </span>
- </>
- );
-
- const defaultRenderOption = (
- option: DropdownOption<T>,
- isSelected: boolean
- ) => (
- <>
- <div class="flex items-center gap-2 flex-1 min-w-0">
- <Show when={option.icon}>
- <span class="shrink-0">{option.icon}</span>
- </Show>
- <div class="flex-1 min-w-0">
- <div class="truncate">{option.label}</div>
- <Show when={option.description}>
- <div class="text-xs text-ink-muted truncate">
- {option.description}
- </div>
- </Show>
- </div>
- </div>
- <Show when={isSelected}>
- <CheckIcon class="size-3 shrink-0" />
- </Show>
- </>
- );
-
- return (
- <div class={props.class ?? ''} ref={dropdownRef}>
- <button
- ref={buttonRef}
- type="button"
- onClick={() => setIsOpen(!isOpen())}
- class="w-full p-1.5 border border-edge-muted bg-surface text-sm text-ink text-left flex items-center gap-2 hover:bg-hover rounded-sm"
- >
- {props.renderValue?.(selectedOption()) ??
- defaultRenderValue(selectedOption())}
- <ChevronDownIcon class="size-3 text-ink-muted shrink-0" />
- </button>
- <Show when={isOpen()}>
- <ScopedPortal scope="local">
- <Layer depth={2}>
- <div
- ref={menuRef}
- class="z-toast-region border border-edge bg-surface shadow-lg max-h-64 overflow-y-auto p-1"
- style={getMenuStyle()}
- >
- <For each={props.options}>
- {(option) => {
- const isSelected = () => option.value === props.value;
- const isDisabled = () => option.disabled ?? false;
-
- return (
- <button
- type="button"
- onClick={() => {
- if (!isDisabled()) {
- props.onChange(option.value);
- setIsOpen(false);
- }
- }}
- disabled={isDisabled()}
- class={cn(
- 'w-full p-1.5 text-sm text-left flex items-center justify-between',
- isDisabled()
- ? 'opacity-50 cursor-not-allowed'
- : isSelected()
- ? 'bg-active text-ink'
- : 'hover:bg-hover text-ink'
- )}
- >
- {props.renderOption?.(option, isSelected()) ??
- defaultRenderOption(option, isSelected())}
- </button>
- );
- }}
- </For>
- </div>
- </Layer>
- </ScopedPortal>
- </Show>
- </div>
- );
-};
diff --git a/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx b/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx
index 76aab9563f..b5e1e34cc4 100644
--- a/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx
+++ b/js/app/packages/property/src/editors/selectors/OptionCheckBox.tsx
@@ -19,6 +19,7 @@ export const OptionCheckBox: Component<{
'bg-accent border-accent border': props.checked,
'bg-transparent border-edge-muted border': !props.checked,
'rounded-full': props.multiselect === false,
+ 'rounded-sm': props.multiselect !== false,
}}
>
<Show when={props.checked && props.multiselect !== false}>
diff --git a/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx b/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
index b7c7fc6607..be9e2a35df 100644
--- a/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
+++ b/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
@@ -391,7 +391,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
return (
<div>
<div class="relative">
- <div class="flex w-full items-center py-1 gap-2 px-2 border-b border-edge-muted">
+ <div class="flex w-full items-center py-2 gap-2 px-2 border-b border-edge-muted">
<SearchIcon class="size-4 text-ink-muted" />
<input
class="w-full caret-accent"
@@ -414,7 +414,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
</div>
<Show when={totalCount() > 0}>
- <div class="p-1">
+ <div class="p-1.5">
<For each={visiblePinnedOptions()}>
{(option, i) => {
const isSelected = () => props.selectedOptions().has(option.id);
@@ -422,7 +422,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
return (
<div
- class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8"
+ class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8 rounded-md"
classList={{
'bg-hover': isKeyboardSelected(),
'bg-accent/10': isSelected(),
@@ -467,7 +467,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
return (
<div
data-entity-index={index()}
- class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8"
+ class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8 rounded-md"
classList={{
'bg-hover': isKeyboardSelected(),
'bg-accent/10': isSelected(),
diff --git a/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx b/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
index 3f62b40928..e8ee4537c9 100644
--- a/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
+++ b/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
@@ -58,10 +58,12 @@ const useDropdownSearch = (options: UseDropdownSearchOptions) => {
const count = options.itemCount();
if (count === 0) return;
- if (shouldShowHotkeys() && /^[1-9]$/.test(e.key)) {
+ if (shouldShowHotkeys() && /^[0-9]$/.test(e.key)) {
e.preventDefault();
- const idx = parseInt(e.key) - 1;
- if (idx < count) options.onSelect(idx);
+ const keyNum = parseInt(e.key);
+ // 0 selects index 0 (the clear option when present)
+ // 1-9 select indices 1-9 (the actual options)
+ if (keyNum < count) options.onSelect(keyNum);
return;
}
@@ -98,7 +100,7 @@ type DropdownSearchInputProps = {
const DropdownSearchInput = (props: DropdownSearchInputProps) => {
return (
- <div class="flex w-full items-center py-1 gap-2 px-2 border-b border-edge-muted">
+ <div class="flex w-full items-center py-2 gap-2 px-2 border-b border-edge-muted">
<SearchIcon class="h-4 w-4 text-ink-muted" />
<input
class="w-full caret-accent"
@@ -126,7 +128,7 @@ const DropdownSelectableRow: ParentComponent<DropdownSelectableRowProps> = (
) => {
return (
<div
- class="flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2"
+ class="flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 rounded-md"
classList={{
'bg-hover': props.isSelected,
}}
@@ -136,9 +138,7 @@ const DropdownSelectableRow: ParentComponent<DropdownSelectableRowProps> = (
<div class="flex items-center gap-2 flex-1 min-w-0">{props.children}</div>
<div class="flex items-center gap-2 shrink-0">
<Show when={props.showHotkey && props.hotkeyShortcut}>
- <div class="text-xxs px-1.5 py-0.5 border border-edge-muted text-ink-muted font-mono rounded-xs">
- <Hotkey shortcut={props.hotkeyShortcut!} />
- </div>
+ <Hotkey shortcut={props.hotkeyShortcut!} theme="subtle" />
</Show>
{props.rightContent}
</div>
@@ -378,7 +378,7 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
</div>
}
>
- <div class="p-1">
+ <div class="p-1.5">
<div class="max-h-50 overflow-y-auto overflow-x-hidden scrollbar-hidden">
<Show
when={selectableItems().length > 0}
@@ -414,9 +414,9 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
}}
onMouseEnter={onMouseEnter}
showHotkey={
- dropdown.shouldShowHotkeys() && index() < 9
+ dropdown.shouldShowHotkeys() && index() <= 9
}
- hotkeyShortcut={`${index() + 1}`}
+ hotkeyShortcut={`${index()}`}
rightContent={
<Show when={props.config.isMultiSelect}>
<OptionCheckBox
@@ -455,6 +455,8 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
}
}}
onMouseEnter={onMouseEnter}
+ showHotkey={dropdown.shouldShowHotkeys()}
+ hotkeyShortcut="0"
>
<CircleDashedEmpty class="size-3 shrink-0 text-ink-extra-muted" />
<div class="flex-1 min-w-0 text-left">
diff --git a/js/app/packages/property/src/editors/selectors/index.ts b/js/app/packages/property/src/editors/selectors/index.ts
index de7d8a0bd9..707cb9eba7 100644
--- a/js/app/packages/property/src/editors/selectors/index.ts
+++ b/js/app/packages/property/src/editors/selectors/index.ts
@@ -1,5 +1,3 @@
-export type { DropdownOption } from './Dropdown';
-export { Dropdown } from './Dropdown';
export {
type CombinedEntity,
createEntitySearchConfig,
diff --git a/js/app/packages/property/src/index.ts b/js/app/packages/property/src/index.ts
index 5fec72ce3d..524379a291 100644
--- a/js/app/packages/property/src/index.ts
+++ b/js/app/packages/property/src/index.ts
@@ -6,8 +6,6 @@ export {} from './editors';
export {
type CombinedEntity,
createEntitySearchConfig,
- Dropdown,
- type DropdownOption,
type EntityTypeItemMap,
getEntityName,
getEntitySearchText,
diff --git a/js/app/packages/theme/constants.ts b/js/app/packages/theme/constants.ts
index 2b75353357..28e2ba981e 100644
--- a/js/app/packages/theme/constants.ts
+++ b/js/app/packages/theme/constants.ts
@@ -87,8 +87,8 @@ export const DEFAULT_THEMES = [
b0: { l: 0.96, c: 0.00, h: 59 },
b1: { l: 0.92, c: 0.00, h: 59 },
b2: { l: 0.91, c: 0.00, h: 59 },
- b3: { l: 0.93, c: 0.00, h: 59 },
- b4: { l: 0.89, c: 0.00, h: 59 },
+ b3: { l: 0.92, c: 0.00, h: 59 },
+ b4: { l: 0.91, c: 0.00, h: 59 },
c0: { l: 0.14, c: 0.00, h: 59 },
c1: { l: 0.40, c: 0.00, h: 59 },
c2: { l: 0.55, c: 0.00, h: 59 },