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.

fix(properties): show a picked value while its save runs (#9124)

gbirmane239ffcdd04f
diff --git a/apps/web/src/features/block-md/component/InlinePropertyValue.tsx b/apps/web/src/features/block-md/component/InlinePropertyValue.tsx
index 9bb8f3e581..67d8e0ca92 100644
--- a/apps/web/src/features/block-md/component/InlinePropertyValue.tsx
+++ b/apps/web/src/features/block-md/component/InlinePropertyValue.tsx
@@ -68,7 +68,6 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
}
canEdit={ctx.canEdit}
onSave={ctx.saveHandler.saveProperty}
- onRefresh={ctx.onRefresh}
onEdit={
props.entityId && usesInlineEditor()
? (property, anchor) =>
diff --git a/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx b/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx
index 79e6b2ab62..b58b4a14e7 100644
--- a/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx
+++ b/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx
@@ -76,8 +76,6 @@ function getEntityType(entity: EntityData): EntityType {
interface EntityKeyPropertiesProps {
/** Entity with properties attached */
entity: EntityWithProperties<EntityData>;
- /** Callback when properties are refreshed */
- onRefresh?: () => void;
/** Max visible user avatars in the assignees stack before collapsing to +N. */
maxUserStackUsers?: number;
/** Whether to show the edit affordance caret. */
@@ -136,14 +134,13 @@ export function EntityKeyProperties(props: EntityKeyPropertiesProps) {
entityType={entityType()}
canEdit={true}
properties={keyProperties}
- onRefresh={props.onRefresh ?? (() => {})}
+ onRefresh={() => {}}
onPropertyAdded={() => {}}
onPropertyDeleted={() => {}}
saveHandler={saveHandler}
>
<KeyPropertiesRow
properties={keyProperties}
- onRefresh={props.onRefresh}
maxUserStackUsers={props.maxUserStackUsers}
showCaret={props.showCaret}
/>
@@ -158,7 +155,6 @@ export function EntityKeyProperties(props: EntityKeyPropertiesProps) {
function KeyPropertiesRow(props: {
properties: Accessor<PropertyT[]>;
- onRefresh?: () => void;
maxUserStackUsers?: number;
showCaret?: boolean;
}) {
@@ -168,86 +164,89 @@ function KeyPropertiesRow(props: {
return (
<div class="flex items-center gap-1 justify-start text-xs">
<For each={props.properties()}>
- {(property) => {
- const isEmpty = () => !hasValue(property);
+ {(property) => (
+ <Property.Root
+ property={property}
+ canEdit={ctx.canEdit}
+ onSave={ctx.saveHandler.saveProperty}
+ >
+ {(shown) => {
+ const isEmpty = () => !hasValue(shown());
- const isUserEntity = () =>
- property.valueType === 'ENTITY' &&
- property.specificEntityType === 'USER';
+ const isUserEntity = () =>
+ shown().valueType === 'ENTITY' &&
+ shown().specificEntityType === 'USER';
- const isMultiUserEntity = () =>
- isUserEntity() && getEntityValues(property).length > 1;
+ const isMultiUserEntity = () =>
+ isUserEntity() && getEntityValues(shown()).length > 1;
- return (
- <Property.Root
- property={property}
- canEdit={ctx.canEdit}
- onSave={ctx.saveHandler.saveProperty}
- onRefresh={ctx.onRefresh}
- >
- <Property.Tooltip property={property}>
- <Layer depth={2}>
- <Property.EditTrigger
- class={cn(
- /* border, not ring: Tailwind rings are box-shadows and
- would fight the glass shadow */
- 'flex items-center gap-1 min-w-0 border border-edge-muted/50 glass',
- 'px-1.5 py-1 leading-tight text-left rounded-full',
- '@max-2xl/u-list:border-0 @max-2xl/u-list:glass-none @max-2xl/u-list:gap-0 @max-2xl/u-list:px-1 @max-2xl/u-list:justify-center',
- {
- 'hover:bg-hover': ctx.canEdit,
- 'text-ink-extra-muted/50': isEmpty(),
- }
- )}
- >
- <div class="h-4" />
- <Switch
- fallback={
- <Property.Icon
- property={property}
- class="size-3 shrink-0 @max-2xl/u-list:size-4"
+ return (
+ <>
+ <Property.Tooltip property={shown()}>
+ <Layer depth={2}>
+ <Property.EditTrigger
+ class={cn(
+ /* border, not ring: Tailwind rings are box-shadows and
+ would fight the glass shadow */
+ 'flex items-center gap-1 min-w-0 border border-edge-muted/50 glass',
+ 'px-1.5 py-1 leading-tight text-left rounded-full',
+ '@max-2xl/u-list:border-0 @max-2xl/u-list:glass-none @max-2xl/u-list:gap-0 @max-2xl/u-list:px-1 @max-2xl/u-list:justify-center',
+ {
+ 'hover:bg-hover': ctx.canEdit,
+ 'text-ink-extra-muted/50': isEmpty(),
+ }
+ )}
+ >
+ <div class="h-4" />
+ <Switch
+ fallback={
+ <Property.Icon
+ property={shown()}
+ class="size-3 shrink-0 @max-2xl/u-list:size-4"
+ />
+ }
+ >
+ <Match when={isMultiUserEntity()}>
+ <Property.UserStack
+ property={shown()}
+ maxUsers={props.maxUserStackUsers ?? 2}
+ avatarClass="@max-2xl/u-list:size-5"
+ />
+ </Match>
+ <Match when={isUserEntity()}>
+ <Property.Icon
+ property={shown()}
+ class="@max-2xl/u-list:size-5"
+ />
+ </Match>
+ </Switch>
+ <Property.Text
+ property={shown()}
+ class="@max-2xl/u-list:hidden"
+ fallback={
+ <>
+ <Property.Empty
+ label="None"
+ class="@max-2xl/u-list:hidden"
+ />
+ <Property.Empty class="hidden @max-2xl/u-list:inline-flex" />
+ </>
+ }
/>
- }
- >
- <Match when={isMultiUserEntity()}>
- <Property.UserStack
- property={property}
- maxUsers={props.maxUserStackUsers ?? 2}
- avatarClass="@max-2xl/u-list:size-5"
- />
- </Match>
- <Match when={isUserEntity()}>
- <Property.Icon
- property={property}
- class="@max-2xl/u-list:size-5"
- />
- </Match>
- </Switch>
- <Property.Text
- property={property}
- class="@max-2xl/u-list:hidden"
- fallback={
- <>
- <Property.Empty
- label="None"
- class="@max-2xl/u-list:hidden"
- />
- <Property.Empty class="hidden @max-2xl/u-list:inline-flex" />
- </>
- }
- />
- <Show when={props.showCaret ?? true}>
- <Property.Caret class="@max-2xl/u-list:hidden" />
- </Show>
- </Property.EditTrigger>
- </Layer>
- </Property.Tooltip>
- <Property.PopoverEditor
- entitySelfFilter={{ entityType: ctx.entityType, blockId }}
- />
- </Property.Root>
- );
- }}
+ <Show when={props.showCaret ?? true}>
+ <Property.Caret class="@max-2xl/u-list:hidden" />
+ </Show>
+ </Property.EditTrigger>
+ </Layer>
+ </Property.Tooltip>
+ <Property.PopoverEditor
+ entitySelfFilter={{ entityType: ctx.entityType, blockId }}
+ />
+ </>
+ );
+ }}
+ </Property.Root>
+ )}
</For>
</div>
);
diff --git a/apps/web/src/features/next-soup/soup-view/views/tasks/list-property-value.tsx b/apps/web/src/features/next-soup/soup-view/views/tasks/list-property-value.tsx
index 48c0e7ab51..83a419b332 100644
--- a/apps/web/src/features/next-soup/soup-view/views/tasks/list-property-value.tsx
+++ b/apps/web/src/features/next-soup/soup-view/views/tasks/list-property-value.tsx
@@ -5,7 +5,7 @@ import { usePropertiesContext } from '@property/context/PropertiesContext';
import type { Property as PropertyT } from '@property/types';
import { getEntityValues, hasValue } from '@property/utils';
import { cn, Layer } from '@ui';
-import { type Component, Match, Show, Switch } from 'solid-js';
+import { type Accessor, type Component, Match, Show, Switch } from 'solid-js';
import './list-property-value.css';
type ListPropertyValueProps = {
@@ -19,16 +19,6 @@ type ListPropertyValueProps = {
*/
export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
const ctx = usePropertiesContext();
- const blockId = useMaybeBlockId();
-
- const isUserEntity = () =>
- props.property.valueType === 'ENTITY' &&
- props.property.specificEntityType === 'USER';
-
- const userCount = () =>
- isUserEntity() ? getEntityValues(props.property).length : 0;
-
- const isEmpty = () => !hasValue(props.property);
// STRING / NUMBER / BOOLEAN / LINK edit in place rather than via the
// EditTrigger + popover pair.
@@ -44,20 +34,21 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
property={props.property}
canEdit={ctx.canEdit}
onSave={ctx.saveHandler.saveProperty}
- onRefresh={ctx.onRefresh}
>
- <Property.Tooltip property={props.property}>
- <Layer depth={2}>
- {/* Stop clicks from bubbling to the row (which opens the entity). */}
- <div
- class="list-property-cell w-full max-w-full min-w-0 overflow-hidden rounded-full hover:bg-surface/50 text-left @max-[840px]/u-list:hidden"
- onClick={(e) => e.stopPropagation()}
- role="presentation"
- >
- <Property.InlineEditor />
- </div>
- </Layer>
- </Property.Tooltip>
+ {(property) => (
+ <Property.Tooltip property={property()}>
+ <Layer depth={2}>
+ {/* Stop clicks from bubbling to the row (which opens the entity). */}
+ <div
+ class="list-property-cell w-full max-w-full min-w-0 overflow-hidden rounded-full hover:bg-surface/50 text-left @max-[840px]/u-list:hidden"
+ onClick={(e) => e.stopPropagation()}
+ role="presentation"
+ >
+ <Property.InlineEditor />
+ </div>
+ </Layer>
+ </Property.Tooltip>
+ )}
</Property.Root>
);
}
@@ -67,9 +58,28 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
property={props.property}
canEdit={ctx.canEdit}
onSave={ctx.saveHandler.saveProperty}
- onRefresh={ctx.onRefresh}
>
- <Property.Tooltip property={props.property}>
+ {(property) => <ListPropertyPill property={property} />}
+ </Property.Root>
+ );
+};
+
+function ListPropertyPill(props: { property: Accessor<PropertyT> }) {
+ const ctx = usePropertiesContext();
+ const blockId = useMaybeBlockId();
+
+ const isUserEntity = () =>
+ props.property().valueType === 'ENTITY' &&
+ props.property().specificEntityType === 'USER';
+
+ const userCount = () =>
+ isUserEntity() ? getEntityValues(props.property()).length : 0;
+
+ const isEmpty = () => !hasValue(props.property());
+
+ return (
+ <>
+ <Property.Tooltip property={props.property()}>
<Layer depth={2}>
<Property.Pill
class={cn(
@@ -86,7 +96,7 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
<>
<CircleDashedEmpty class="size-3 shrink-0 opacity-50" />
<span class="truncate flex-1 opacity-50 @max-[840px]/u-list:hidden">
- {props.property.displayName}
+ {props.property().displayName}
</span>
</>
}
@@ -94,7 +104,7 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
<Switch
fallback={
<Property.Icon
- property={props.property}
+ property={props.property()}
class="size-3 shrink-0"
/>
}
@@ -103,13 +113,13 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
{/* Wide: 2 avatars; narrow: collapse to 1 to fit the cell. */}
<div class="@max-[840px]/u-list:hidden">
<Property.UserStack
- property={props.property}
+ property={props.property()}
maxUsers={2}
/>
</div>
<div class="hidden @max-[840px]/u-list:flex">
<Property.UserStack
- property={props.property}
+ property={props.property()}
maxUsers={1}
avatarClass="@max-[840px]/u-list:size-4"
/>
@@ -117,13 +127,13 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
</Match>
<Match when={isUserEntity()}>
<Property.Icon
- property={props.property}
+ property={props.property()}
class="@max-[840px]/u-list:size-4"
/>
</Match>
</Switch>
<Property.Text
- property={props.property}
+ property={props.property()}
class="min-w-0 max-w-full flex-1 @max-[840px]/u-list:hidden"
/>
</Show>
@@ -134,6 +144,6 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
<Property.PopoverEditor
entitySelfFilter={{ entityType: ctx.entityType, blockId }}
/>
- </Property.Root>
+ </>
);
-};
+}
diff --git a/apps/web/src/features/projects/views/project-workspace.tsx b/apps/web/src/features/projects/views/project-workspace.tsx
index 9861671848..922b382403 100644
--- a/apps/web/src/features/projects/views/project-workspace.tsx
+++ b/apps/web/src/features/projects/views/project-workspace.tsx
@@ -146,7 +146,6 @@ export function ProjectWorkspace(props: {
value
)
}
- onRefresh={props.source.refresh}
entitySelfFilter={{
blockId: props.project.id,
entityType: 'INITIATIVE',
diff --git a/apps/web/src/features/property/README.md b/apps/web/src/features/property/README.md
index bb63c20078..2fd311edaf 100644
--- a/apps/web/src/features/property/README.md
+++ b/apps/web/src/features/property/README.md
@@ -9,6 +9,13 @@ in any layout, replacing the duplicated `PropertyValue` / `CondensedPropertyValu
Debug page: `/props-debug` (LOCAL_ONLY).
+`Property.Root` shows a pick from the moment an editor saves it until the save
+settles and the source emits a newer property, and drops it if the save fails.
+Pass its children as a function (`{(property) => ...}`) and render from that
+property, not the prop you passed in. Save handlers keep their own caches
+current, so `Property.Root` editors never refetch properties after a save;
+side-panel collections own their refresh (below).
+
## Side-panel collections
Property rows use a 4px vertical gap, including inline Tags and the boundary
diff --git a/apps/web/src/features/property/component/ListPropertyValue.test.tsx b/apps/web/src/features/property/component/ListPropertyValue.test.tsx
index 560238b876..c78cce176d 100644
--- a/apps/web/src/features/property/component/ListPropertyValue.test.tsx
+++ b/apps/web/src/features/property/component/ListPropertyValue.test.tsx
@@ -9,7 +9,10 @@ vi.mock('@property', async () => {
const passthrough = (props: { children: JSX.Element }) => props.children;
return {
Property: {
- Root: passthrough,
+ Root: (props: {
+ property: EntityProperty;
+ children: (property: () => EntityProperty) => JSX.Element;
+ }) => props.children(() => props.property),
Tooltip: passthrough,
EditTrigger: (props: JSX.ButtonHTMLAttributes<HTMLButtonElement>) => (
<button {...props} />
diff --git a/apps/web/src/features/property/component/ListPropertyValue.tsx b/apps/web/src/features/property/component/ListPropertyValue.tsx
index 8bc3a24666..2dbf8a2094 100644
--- a/apps/web/src/features/property/component/ListPropertyValue.tsx
+++ b/apps/web/src/features/property/component/ListPropertyValue.tsx
@@ -4,7 +4,7 @@ import { usePropertiesContext } from '@property/context/PropertiesContext';
import type { Property as PropertyType } from '@property/types';
import { getEntityValues, hasValue } from '@property/utils';
import { Layer } from '@ui';
-import { Match, Show, Switch } from 'solid-js';
+import { type Accessor, Match, Show, Switch } from 'solid-js';
/** Shared property cell for unified task and native project lists. */
export function ListPropertyValue(props: {
@@ -12,14 +12,6 @@ export function ListPropertyValue(props: {
entityId: string;
}) {
const context = usePropertiesContext();
- const isUserEntity = () =>
- props.property.valueType === 'ENTITY' &&
- props.property.specificEntityType === 'USER';
- const userCount = () => {
- if (!isUserEntity()) return 0;
- return getEntityValues(props.property).length;
- };
- const isEmpty = () => !hasValue(props.property);
const isInlineType = () =>
props.property.valueType === 'STRING' ||
props.property.valueType === 'NUMBER' ||
@@ -33,19 +25,20 @@ export function ListPropertyValue(props: {
property={props.property}
canEdit={context.canEdit}
onSave={context.saveHandler.saveProperty}
- onRefresh={context.onRefresh}
>
- <Property.Tooltip property={props.property}>
- <Layer depth={2}>
- <div
- role="presentation"
- class="list-property-cell w-full max-w-full min-w-0 overflow-hidden rounded-full text-left hover:bg-surface/50 @max-[840px]/u-list:hidden"
- onClick={(event) => event.stopPropagation()}
- >
- <Property.InlineEditor />
- </div>
- </Layer>
- </Property.Tooltip>
+ {(property) => (
+ <Property.Tooltip property={property()}>
+ <Layer depth={2}>
+ <div
+ role="presentation"
+ class="list-property-cell w-full max-w-full min-w-0 overflow-hidden rounded-full text-left hover:bg-surface/50 @max-[840px]/u-list:hidden"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <Property.InlineEditor />
+ </div>
+ </Layer>
+ </Property.Tooltip>
+ )}
</Property.Root>
);
}
@@ -56,9 +49,31 @@ export function ListPropertyValue(props: {
property={props.property}
canEdit={context.canEdit}
onSave={context.saveHandler.saveProperty}
- onRefresh={context.onRefresh}
>
- <Property.Tooltip property={props.property}>
+ {(property) => (
+ <ListPropertyCell property={property} entityId={props.entityId} />
+ )}
+ </Property.Root>
+ );
+}
+
+function ListPropertyCell(props: {
+ property: Accessor<PropertyType>;
+ entityId: string;
+}) {
+ const context = usePropertiesContext();
+ const isUserEntity = () =>
+ props.property().valueType === 'ENTITY' &&
+ props.property().specificEntityType === 'USER';
+ const userCount = () => {
+ if (!isUserEntity()) return 0;
+ return getEntityValues(props.property()).length;
+ };
+ const isEmpty = () => !hasValue(props.property());
+
+ return (
+ <>
+ <Property.Tooltip property={props.property()}>
<Layer depth={2}>
<Property.EditTrigger class="list-property-cell inline-flex w-full max-w-full min-w-0 items-center gap-1 overflow-hidden rounded-full px-2 py-1.5 text-left leading-tight hover:bg-surface/50 @max-[840px]/u-list:px-1">
<Show
@@ -67,7 +82,7 @@ export function ListPropertyValue(props: {
<>
<CircleDashedEmpty class="size-3 shrink-0 opacity-50 @max-[840px]/u-list:size-4" />
<span class="min-w-0 flex-1 truncate opacity-50 @max-[840px]/u-list:hidden">
- {props.property.displayName}
+ {props.property().displayName}
</span>
</>
}
@@ -75,7 +90,7 @@ export function ListPropertyValue(props: {
<Switch
fallback={
<Property.Icon
- property={props.property}
+ property={props.property()}
class="size-3 shrink-0 @max-[840px]/u-list:size-4"
/>
}
@@ -83,13 +98,13 @@ export function ListPropertyValue(props: {
<Match when={userCount() > 1}>
<div class="@max-[840px]/u-list:hidden">
<Property.UserStack
- property={props.property}
+ property={props.property()}
maxUsers={2}
/>
</div>
<div class="hidden @max-[840px]/u-list:flex">
<Property.UserStack
- property={props.property}
+ property={props.property()}
maxUsers={1}
avatarClass="@max-[840px]/u-list:size-5"
/>
@@ -97,15 +112,15 @@ export function ListPropertyValue(props: {
</Match>
<Match when={isUserEntity()}>
<Property.Icon
- property={props.property}
+ property={props.property()}
class="@max-[840px]/u-list:size-5"
/>
</Match>
</Switch>
<Property.Text
- property={props.property}
+ property={props.property()}
resolveSingleEntity={
- props.property.specificEntityType === 'INITIATIVE'
+ props.property().specificEntityType === 'INITIATIVE'
}
class="min-w-0 max-w-full flex-1 @max-[840px]/u-list:hidden"
/>
@@ -120,6 +135,6 @@ export function ListPropertyValue(props: {
blockId: props.entityId,
}}
/>
- </Property.Root>
+ </>
);
}
diff --git a/apps/web/src/features/property/component/PropertyValuePill.tsx b/apps/web/src/features/property/component/PropertyValuePill.tsx
index ce15e02379..8de3c4eb00 100644
--- a/apps/web/src/features/property/component/PropertyValuePill.tsx
+++ b/apps/web/src/features/property/component/PropertyValuePill.tsx
@@ -4,7 +4,7 @@ import { getEntityValues, hasValue } from '../utils';
type PropertyValuePillProps = Pick<
ComponentProps<typeof Property.Root>,
- 'property' | 'canEdit' | 'onSave' | 'onRefresh' | 'onEdit'
+ 'property' | 'canEdit' | 'onSave' | 'onEdit'
> & {
emptyLabel?: JSX.Element;
showLabel?: boolean;
@@ -20,69 +20,74 @@ type PropertyValuePillProps = Pick<
/** Controlled property pill shared by task and project composers. */
export function PropertyValuePill(props: PropertyValuePillProps) {
- const isUserEntity = () =>
- props.property.valueType === 'ENTITY' &&
- props.property.specificEntityType === 'USER';
- const isMultiUserEntity = () =>
- isUserEntity() && getEntityValues(props.property).length > 1;
-
return (
<Property.Root
property={props.property}
canEdit={props.canEdit}
onSave={props.onSave}
- onRefresh={props.onRefresh}
onEdit={props.onEdit}
>
- <Property.Tooltip
- property={props.property}
- actions={props.hoverActions}
- trailingAction={props.hoverTrailingAction}
- >
- <Property.Pill
- class={props.class}
- variant={props.variant ?? 'outline'}
- size={props.size}
- >
- <Show when={props.showLabel && hasValue(props.property)}>
- <span class="shrink-0 text-ink-muted">
- {props.property.displayName}:
- </span>
- </Show>
- <span class="inline-flex min-w-0 items-center gap-1">
- <Switch
- fallback={
- <Property.Icon
- property={props.property}
- class="size-3 shrink-0"
- />
- }
+ {(property) => {
+ const isUserEntity = () =>
+ property().valueType === 'ENTITY' &&
+ property().specificEntityType === 'USER';
+ const isMultiUserEntity = () =>
+ isUserEntity() && getEntityValues(property()).length > 1;
+
+ return (
+ <>
+ <Property.Tooltip
+ property={property()}
+ actions={props.hoverActions}
+ trailingAction={props.hoverTrailingAction}
>
- <Match when={isMultiUserEntity()}>
- <Property.UserStack property={props.property} maxUsers={2} />
- </Match>
- <Match when={isUserEntity()}>
- <Property.Icon property={props.property} />
- </Match>
- </Switch>
- <Property.Text
- property={props.property}
- resolveSingleEntity={
- props.showLabel ||
- props.property.specificEntityType === 'INITIATIVE'
- }
- class="min-w-0 max-w-60"
- fallback={
- <Property.Empty
- label={props.emptyLabel ?? props.property.displayName}
- />
- }
- />
- </span>
- <Property.Caret />
- </Property.Pill>
- </Property.Tooltip>
- <Property.PopoverEditor entitySelfFilter={props.entitySelfFilter} />
+ <Property.Pill
+ class={props.class}
+ variant={props.variant ?? 'outline'}
+ size={props.size}
+ >
+ <Show when={props.showLabel && hasValue(property())}>
+ <span class="shrink-0 text-ink-muted">
+ {property().displayName}:
+ </span>
+ </Show>
+ <span class="inline-flex min-w-0 items-center gap-1">
+ <Switch
+ fallback={
+ <Property.Icon
+ property={property()}
+ class="size-3 shrink-0"
+ />
+ }
+ >
+ <Match when={isMultiUserEntity()}>
+ <Property.UserStack property={property()} maxUsers={2} />
+ </Match>
+ <Match when={isUserEntity()}>
+ <Property.Icon property={property()} />
+ </Match>
+ </Switch>
+ <Property.Text
+ property={property()}
+ resolveSingleEntity={
+ props.showLabel ||
+ property().specificEntityType === 'INITIATIVE'
+ }
+ class="min-w-0 max-w-60"
+ fallback={
+ <Property.Empty
+ label={props.emptyLabel ?? property().displayName}
+ />
+ }
+ />
+ </span>
+ <Property.Caret />
+ </Property.Pill>
+ </Property.Tooltip>
+ <Property.PopoverEditor entitySelfFilter={props.entitySelfFilter} />
+ </>
+ );
+ }}
</Property.Root>
);
}
diff --git a/apps/web/src/features/property/composed/PropertyDisplay.tsx b/apps/web/src/features/property/composed/PropertyDisplay.tsx
index f3feede44e..cd599f8ce7 100644
--- a/apps/web/src/features/property/composed/PropertyDisplay.tsx
+++ b/apps/web/src/features/property/composed/PropertyDisplay.tsx
@@ -212,7 +212,6 @@ function EntityDisplay(props: { isReadOnly: boolean }) {
valueType: 'ENTITY',
refs: remaining.length > 0 ? remaining : null,
});
- ctx.onRefresh?.();
};
return (
diff --git a/apps/web/src/features/property/core/Root.test.tsx b/apps/web/src/features/property/core/Root.test.tsx
new file mode 100644
index 0000000000..d8199420a7
--- /dev/null
+++ b/apps/web/src/features/property/core/Root.test.tsx
@@ -0,0 +1,124 @@
+import { fireAndForget } from '@core/util/fireAndForget';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, expect, it, vi } from 'vitest';
+import type { SelectProperty } from '../types';
+import { getSelectValues } from '../utils/typeGuards';
+import { useProperty } from './context';
+import { Root } from './Root';
+
+vi.mock('@core/component/HoverCard', () => ({
+ useHoldParentHoverCardOpen: () => {},
+}));
+
+const priority: SelectProperty = {
+ propertyId: 'priority-assignment',
+ propertyDefinitionId: 'priority-definition',
+ displayName: 'Priority',
+ isMultiSelect: false,
+ owner: { scope: 'system' },
+ createdAt: new Date(0),
+ updatedAt: new Date(0),
+ valueType: 'SELECT_STRING',
+ value: ['low'],
+};
+
+function Pick(props: { option: string }) {
+ const ctx = useProperty();
+ const pick = async () => {
+ try {
+ await ctx.onSave?.(ctx.property(), {
+ valueType: 'SELECT_STRING',
+ values: [props.option],
+ });
+ } catch {
+ // Each test settles its saves.
+ }
+ };
+ return (
+ <button onClick={() => fireAndForget(pick(), 'property-root-test')}>
+ Pick {props.option}
+ </button>
+ );
+}
+
+function setup() {
+ const [source, setSource] = createSignal<SelectProperty>(priority);
+ const saves: PromiseWithResolvers<void>[] = [];
+ const onSave = vi.fn(() => {
+ const save = Promise.withResolvers<void>();
+ saves.push(save);
+ return save.promise;
+ });
+ render(() => (
+ <Root property={source()} canEdit onSave={onSave}>
+ {(shown) => (
+ <>
+ <output>{getSelectValues(shown()).join(',')}</output>
+ <Pick option="high" />
+ <Pick option="urgent" />
+ </>
+ )}
+ </Root>
+ ));
+ const shown = () => screen.getByRole('status').textContent;
+ return { saves, onSave, setSource, shown };
+}
+
+afterEach(cleanup);
+
+it('shows a pick while it saves and until the source moves past it', async () => {
+ const { saves, onSave, setSource, shown } = setup();
+
+ fireEvent.click(screen.getByText('Pick high'));
+ expect(shown()).toBe('high');
+ expect(onSave).toHaveBeenCalledExactlyOnceWith(priority, {
+ valueType: 'SELECT_STRING',
+ values: ['high'],
+ });
+
+ // An unrelated emission before the save settles keeps the pick.
+ setSource({ ...priority });
+ expect(shown()).toBe('high');
+
+ saves[0].resolve();
+ await saves[0].promise;
+ expect(shown()).toBe('high');
+
+ setSource({ ...priority, value: ['high'] });
+ expect(shown()).toBe('high');
+ setSource({ ...priority, value: ['medium'] });
+ expect(shown()).toBe('medium');
+});
+
+it('drops a failed pick without clearing a newer one', async () => {
+ const { saves, shown } = setup();
+
+ fireEvent.click(screen.getByText('Pick high'));
+ fireEvent.click(screen.getByText('Pick urgent'));
+ expect(shown()).toBe('urgent');
+
+ saves[0].reject(new Error('rejected'));
+ await expect(saves[0].promise).rejects.toThrow('rejected');
+ expect(shown()).toBe('urgent');
+
+ saves[1].reject(new Error('rejected'));
+ await expect(saves[1].promise).rejects.toThrow('rejected');
+ expect(shown()).toBe('low');
+});
+
+it('keeps a saving pick through ID assignment but not on another property', () => {
+ const { setSource, shown } = setup();
+
+ fireEvent.click(screen.getByText('Pick high'));
+ setSource({ ...priority, propertyId: 'assigned-after-save' });
+ expect(shown()).toBe('high');
+
+ setSource({
+ ...priority,
+ propertyId: 'status-assignment',
+ propertyDefinitionId: 'status-definition',
+ value: ['todo'],
+ });
+ expect(shown()).toBe('todo');
+});
diff --git a/apps/web/src/features/property/core/Root.tsx b/apps/web/src/features/property/core/Root.tsx
index 1e18a4e61f..c0eb0b92ad 100644
--- a/apps/web/src/features/property/core/Root.tsx
+++ b/apps/web/src/features/property/core/Root.tsx
@@ -1,8 +1,16 @@
import { useHoldParentHoverCardOpen } from '@core/component/HoverCard';
import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
import { cn, Dropdown } from '@ui';
-import { createSignal, type JSX, splitProps } from 'solid-js';
-import type { Property } from '../types';
+import {
+ type Accessor,
+ createMemo,
+ createSignal,
+ type JSX,
+ splitProps,
+ untrack,
+} from 'solid-js';
+import type { Property, PropertyApiValues } from '../types';
+import { withApiValues } from '../utils/transforms';
import {
type PropertyEditFn,
PropertyRootContext,
@@ -11,21 +19,36 @@ import {
} from './context';
interface PropertyRootProps
- extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'onSave' | 'property'> {
+ extends Omit<
+ JSX.HTMLAttributes<HTMLDivElement>,
+ 'onSave' | 'property' | 'children'
+ > {
property: Property;
canEdit?: boolean;
onSave?: PropertySaveFn;
onEdit?: PropertyEditFn;
- onRefresh?: () => void;
+ /** A function receives the property as shown, including a pick still saving. */
+ children?: JSX.Element | ((property: Accessor<Property>) => JSX.Element);
}
+/**
+ * A pick the source has not shown yet. `base` is unset while the save runs;
+ * after it succeeds, the pick stays until the source emits a newer property.
+ * The definition ID survives a new property's ID assignment mid-save, but not
+ * a Root that is reused for another property.
+ */
+type PendingValue = {
+ value: PropertyApiValues;
+ propertyDefinitionId: string;
+ base?: Property;
+};
+
export function Root(props: PropertyRootProps) {
const [local, rest] = splitProps(props, [
'property',
'canEdit',
'onSave',
'onEdit',
- 'onRefresh',
'class',
'children',
]);
@@ -37,6 +60,35 @@ export function Root(props: PropertyRootProps) {
useHoldParentHoverCardOpen(editorOpen);
+ // Editors close before their save finishes, and the source only catches up
+ // once the cache projects the write, so show the pick until then.
+ const [pending, setPending] = createSignal<PendingValue>();
+ const property = createMemo(() => {
+ const current = pending();
+ return current &&
+ current.propertyDefinitionId === local.property.propertyDefinitionId &&
+ (current.base === undefined || current.base === local.property)
+ ? withApiValues(local.property, current.value)
+ : local.property;
+ });
+
+ const save: PropertySaveFn = async (saved, value) => {
+ const onSave = local.onSave;
+ if (!onSave) return;
+ const entry: PendingValue = {
+ value,
+ propertyDefinitionId: saved.propertyDefinitionId,
+ };
+ setPending(entry);
+ try {
+ await onSave(saved, value);
+ if (pending() === entry) setPending({ ...entry, base: local.property });
+ } catch (error) {
+ if (pending() === entry) setPending(undefined);
+ throw error;
+ }
+ };
+
// Focus restoration helper - used by both closeEditor and onOpenChange
// When a value is saved, the component may remount (due to reactive updates),
// so we fall back to finding the trigger by property ID if the anchor is stale.
@@ -64,17 +116,14 @@ export function Root(props: PropertyRootProps) {
};
const value: PropertyRootContextValue = {
- property: () => local.property,
+ property,
canEdit: () => local.canEdit ?? false,
get onSave() {
- return local.onSave;
+ return local.onSave && save;
},
get onEdit() {
return local.onEdit;
},
- get onRefresh() {
- return local.onRefresh;
- },
editorOpen,
openEditor: (anchor) => {
if (anchor) setEditorAnchor(() => anchor);
@@ -86,6 +135,13 @@ export function Root(props: PropertyRootProps) {
},
};
+ const children = () => {
+ const content = local.children;
+ return typeof content === 'function'
+ ? untrack(() => content(property))
+ : content;
+ };
+
const handleOpenChange = (open: boolean) => {
setEditorOpen(open);
if (!open) {
@@ -109,7 +165,7 @@ export function Root(props: PropertyRootProps) {
data-property-type={local.property.valueType}
{...rest}
>
- {local.children}
+ {children()}
</div>
</Dropdown>
</PropertyRootContext.Provider>
diff --git a/apps/web/src/features/property/core/context.ts b/apps/web/src/features/property/core/context.ts
index c87fedf818..7ae5068b8e 100644
--- a/apps/web/src/features/property/core/context.ts
+++ b/apps/web/src/features/property/core/context.ts
@@ -9,11 +9,12 @@ export type PropertySaveFn = (
export type PropertyEditFn = (property: Property, anchor?: HTMLElement) => void;
export interface PropertyRootContextValue {
+ /** The property as shown: a pick still saving replaces the source value. */
property: () => Property;
canEdit: () => boolean;
+ /** Saves through the consumer's handler and shows the pick until then. */
onSave?: PropertySaveFn;
onEdit?: PropertyEditFn;
- onRefresh?: () => void;
// Local editor open state. Populated by EditTrigger when the consumer hasn't
// supplied an external onEdit; consumed by PopoverEditor. The anchor passed
diff --git a/apps/web/src/features/property/editors/hooks/useBooleanEditor.ts b/apps/web/src/features/property/editors/hooks/useBooleanEditor.ts
index 8ba782ae68..c28b31cca4 100644
--- a/apps/web/src/features/property/editors/hooks/useBooleanEditor.ts
+++ b/apps/web/src/features/property/editors/hooks/useBooleanEditor.ts
@@ -30,7 +30,6 @@ export function useBooleanEditor(): {
const current = property.value as boolean | null;
const next = current === null ? true : !current;
await ctx.onSave?.(property, { valueType: 'BOOLEAN', value: next });
- ctx.onRefresh?.();
} catch {
// onSave callers own error UX.
} finally {
diff --git a/apps/web/src/features/property/editors/hooks/useInlineEditor.ts b/apps/web/src/features/property/editors/hooks/useInlineEditor.ts
index 76b17660f5..b2a8f469a9 100644
--- a/apps/web/src/features/property/editors/hooks/useInlineEditor.ts
+++ b/apps/web/src/features/property/editors/hooks/useInlineEditor.ts
@@ -74,7 +74,6 @@ export function useInlineEditor(): {
}
await ctx.onSave?.(property, apiValues);
setIsEditing(false);
- ctx.onRefresh?.();
} catch {
// onSave callers (mutations) own error UX via onError toasts.
} finally {
diff --git a/apps/web/src/features/property/editors/inline/InlineLinkEditor.tsx b/apps/web/src/features/property/editors/inline/InlineLinkEditor.tsx
index 5cd16e2dd6..15172c9d4c 100644
--- a/apps/web/src/features/property/editors/inline/InlineLinkEditor.tsx
+++ b/apps/web/src/features/property/editors/inline/InlineLinkEditor.tsx
@@ -88,7 +88,6 @@ export function InlineLinkEditor() {
: [normalized];
await ctx.onSave?.(property(), { valueType: 'LINK', values: next });
cancelAdding();
- ctx.onRefresh?.();
} catch {
// mutation onError owns toast
} finally {
@@ -105,7 +104,6 @@ export function InlineLinkEditor() {
valueType: 'LINK',
values: next.length > 0 ? next : null,
});
- ctx.onRefresh?.();
} catch {
// mutation onError owns toast
} finally {
diff --git a/apps/web/src/features/property/editors/popover/DateEditor.tsx b/apps/web/src/features/property/editors/popover/DateEditor.tsx
index b372a724eb..437e02ffbb 100644
--- a/apps/web/src/features/property/editors/popover/DateEditor.tsx
+++ b/apps/web/src/features/property/editors/popover/DateEditor.tsx
@@ -33,7 +33,6 @@ function DateEditorBody() {
setSelectedDate(date);
try {
await ctx.onSave?.(property, { valueType: 'DATE', value: date });
- ctx.onRefresh?.();
} catch {
// mutation onError owns toast
}
diff --git a/apps/web/src/features/property/editors/popover/DateRangeEditor.tsx b/apps/web/src/features/property/editors/popover/DateRangeEditor.tsx
index bb2c7033e8..d31f1476a6 100644
--- a/apps/web/src/features/property/editors/popover/DateRangeEditor.tsx
+++ b/apps/web/src/features/property/editors/popover/DateRangeEditor.tsx
@@ -30,7 +30,6 @@ function DateRangeEditorBody(props: { property: DateRangeProperty }) {
valueType: 'DATE_RANGE',
value: range,
});
- ctx.onRefresh?.();
} catch {
// mutation onError owns toast
}
diff --git a/apps/web/src/features/property/editors/popover/EntityEditor.tsx b/apps/web/src/features/property/editors/popover/EntityEditor.tsx
index 0c26f4e241..82c8af4ddb 100644
--- a/apps/web/src/features/property/editors/popover/EntityEditor.tsx
+++ b/apps/web/src/features/property/editors/popover/EntityEditor.tsx
@@ -82,7 +82,6 @@ function EntityEditorBody(props: EntityEditorProps) {
};
try {
await ctx.onSave?.(property, apiValues);
- ctx.onRefresh?.();
} catch {
// mutation onError owns toast
}
diff --git a/apps/web/src/features/property/editors/popover/SelectEditor.test.tsx b/apps/web/src/features/property/editors/popover/SelectEditor.test.tsx
index 0aa087a005..7c6285eb59 100644
--- a/apps/web/src/features/property/editors/popover/SelectEditor.test.tsx
+++ b/apps/web/src/features/property/editors/popover/SelectEditor.test.tsx
@@ -90,7 +90,6 @@ const property: SelectProperty = {
function setup(value = property) {
const pending = Promise.withResolvers<void>();
const onSave = vi.fn(() => pending.promise);
- const onRefresh = vi.fn();
const [editorOpen, setEditorOpen] = createSignal(true);
const context: PropertyRootContextValue = {
property: () => value,
@@ -99,14 +98,13 @@ function setup(value = property) {
openEditor: () => setEditorOpen(true),
closeEditor: () => setEditorOpen(false),
onSave,
- onRefresh,
};
render(() => (
<PropertyRootContext.Provider value={context}>
<SelectEditor />
</PropertyRootContext.Provider>
));
- return { pending, onSave, onRefresh, context };
+ return { pending, onSave, context };
}
afterEach(cleanup);
@@ -191,7 +189,7 @@ it('does not rewrite an existing project status when its picker is dismissed', (
describe('SelectEditor save dismissal', () => {
it('closes immediately while saving the selected status', async () => {
- const { pending, onSave, onRefresh, context } = setup();
+ const { pending, onSave, context } = setup();
fireEvent.click(screen.getByText('Pick option'));
@@ -200,19 +198,17 @@ describe('SelectEditor save dismissal', () => {
valueType: 'SELECT_STRING',
values: ['doing'],
});
- expect(onRefresh).not.toHaveBeenCalled();
// A slow earlier save must not dismiss a newly opened editor.
context.openEditor();
expect(screen.queryByRole('dialog')).not.toBeNull();
pending.resolve();
await pending.promise;
- expect(onRefresh).toHaveBeenCalledOnce();
expect(screen.queryByRole('dialog')).not.toBeNull();
});
- it('stays closed on a failed save without refreshing or resubmitting', async () => {
- const { pending, onSave, onRefresh } = setup();
+ it('stays closed on a failed save without resubmitting', async () => {
+ const { pending, onSave } = setup();
fireEvent.click(screen.getByText('Pick option'));
expect(screen.queryByRole('dialog')).toBeNull();
@@ -222,17 +218,15 @@ describe('SelectEditor save dismissal', () => {
expect(screen.queryByRole('dialog')).toBeNull();
expect(onSave).toHaveBeenCalledOnce();
- expect(onRefresh).not.toHaveBeenCalled();
});
it('closes without saving when nothing changed', () => {
- const { onSave, onRefresh } = setup();
+ const { onSave } = setup();
fireEvent.click(screen.getByText('Dismiss'));
expect(screen.queryByRole('dialog')).toBeNull();
expect(onSave).not.toHaveBeenCalled();
- expect(onRefresh).not.toHaveBeenCalled();
});
it('captures accumulated multi-select values before unmounting on dismissal', async () => {
diff --git a/apps/web/src/features/property/editors/popover/SelectEditor.tsx b/apps/web/src/features/property/editors/popover/SelectEditor.tsx
index 6259700ce2..52d8c7f58b 100644
--- a/apps/web/src/features/property/editors/popover/SelectEditor.tsx
+++ b/apps/web/src/features/property/editors/popover/SelectEditor.tsx
@@ -68,7 +68,6 @@ function SelectEditorBody() {
};
try {
await ctx.onSave?.(property, apiValues);
- ctx.onRefresh?.();
} catch {
// mutation onError owns toast
}
diff --git a/apps/web/src/features/property/extractors/PropertyRemoveButton.tsx b/apps/web/src/features/property/extractors/PropertyRemoveButton.tsx
index fe63f69ede..1f4ed94b85 100644
--- a/apps/web/src/features/property/extractors/PropertyRemoveButton.tsx
+++ b/apps/web/src/features/property/extractors/PropertyRemoveButton.tsx
@@ -38,7 +38,6 @@ export function PropertyRemoveButton(props: Props) {
try {
const next = nextValue(property, props.valueToRemove);
if (next) await save(property, next);
- ctx.onRefresh?.();
} finally {
setIsSaving(false);
}
diff --git a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
index 6415277a9b..618a8d91f5 100644
--- a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
+++ b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
@@ -606,40 +606,43 @@ function SidePanelPropertyRow(props: {
property={props.property}
canEdit={ctx.canEdit}
onSave={ctx.saveHandler.saveProperty}
- onRefresh={ctx.onRefresh}
>
- <Switch
- fallback={
- <SinglePill
- getEmptyLabel={props.getEmptyLabel}
- property={props.property}
+ {(property) => (
+ <>
+ <Switch
+ fallback={
+ <SinglePill
+ getEmptyLabel={props.getEmptyLabel}
+ property={property()}
+ />
+ }
+ >
+ <Match when={isInputType()}>
+ <InputValue />
+ </Match>
+ <Match when={isMultiValueRow()}>
+ <MultiValue property={property()}>
+ <PropertyRowActions.Root
+ canRemoveFromEntity={props.canRemoveFromEntity}
+ canPinPendingProperty={props.canPinPendingProperty}
+ property={props.property}
+ onRemovePendingProperty={props.onRemovePendingProperty}
+ onPropertyPinned={props.onPropertyPinned}
+ >
+ <PropertyRowActions.Pin />
+ <PropertyRowActions.Remove />
+ </PropertyRowActions.Root>
+ </MultiValue>
+ </Match>
+ </Switch>
+ <PropertyNS.PopoverEditor
+ entitySelfFilter={{
+ entityType: ctx.entityType,
+ blockId: props.entityId,
+ }}
/>
- }
- >
- <Match when={isInputType()}>
- <InputValue />
- </Match>
- <Match when={isMultiValueRow()}>
- <MultiValue property={props.property}>
- <PropertyRowActions.Root
- canRemoveFromEntity={props.canRemoveFromEntity}
- canPinPendingProperty={props.canPinPendingProperty}
- property={props.property}
- onRemovePendingProperty={props.onRemovePendingProperty}
- onPropertyPinned={props.onPropertyPinned}
- >
- <PropertyRowActions.Pin />
- <PropertyRowActions.Remove />
- </PropertyRowActions.Root>
- </MultiValue>
- </Match>
- </Switch>
- <PropertyNS.PopoverEditor
- entitySelfFilter={{
- entityType: ctx.entityType,
- blockId: props.entityId,
- }}
- />
+ </>
+ )}
</PropertyNS.Root>
<Show when={!hasInlineAddAction()}>
<PropertyRowActions.Root
@@ -809,11 +812,10 @@ function NonUserEntityValue(props: {
const remaining = entities().filter(
(entity) => entity.entity_id !== entityId
);
- await ctx.saveHandler.saveProperty(props.property, {
+ await propertyCtx.onSave?.(props.property, {
valueType: 'ENTITY',
refs: remaining.length > 0 ? remaining : null,
});
- ctx.onRefresh();
};
return (
diff --git a/apps/web/src/features/property/utils/transforms.ts b/apps/web/src/features/property/utils/transforms.ts
index 6275c2bbb2..9d38ae6155 100644
--- a/apps/web/src/features/property/utils/transforms.ts
+++ b/apps/web/src/features/property/utils/transforms.ts
@@ -1,6 +1,59 @@
import type { PropertyDefinition } from '@service-properties/generated/schemas/propertyDefinition';
import type { PropertyOption } from '@service-properties/generated/schemas/propertyOption';
-import type { PropertyDefinitionDomain } from '../types';
+import { match } from 'ts-pattern';
+import type {
+ Property,
+ PropertyApiValues,
+ PropertyDefinitionDomain,
+} from '../types';
+
+/** The property as it reads once `apiValues` is saved. */
+export function withApiValues(
+ property: Property,
+ apiValues: PropertyApiValues
+): Property {
+ return (
+ match([property, apiValues])
+ .with(
+ [{ valueType: 'STRING' }, { valueType: 'STRING' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.value })
+ )
+ .with(
+ [{ valueType: 'NUMBER' }, { valueType: 'NUMBER' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.value })
+ )
+ .with(
+ [{ valueType: 'BOOLEAN' }, { valueType: 'BOOLEAN' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.value })
+ )
+ .with(
+ [{ valueType: 'DATE' }, { valueType: 'DATE' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.value })
+ )
+ .with(
+ [{ valueType: 'DATE_RANGE' }, { valueType: 'DATE_RANGE' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.value })
+ )
+ .with(
+ [{ valueType: 'SELECT_STRING' }, { valueType: 'SELECT_STRING' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.values })
+ )
+ .with(
+ [{ valueType: 'SELECT_NUMBER' }, { valueType: 'SELECT_NUMBER' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.values })
+ )
+ .with(
+ [{ valueType: 'ENTITY' }, { valueType: 'ENTITY' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.refs })
+ )
+ .with(
+ [{ valueType: 'LINK' }, { valueType: 'LINK' }],
+ ([property, apiValues]) => ({ ...property, value: apiValues.values })
+ )
+ // Values of another type can't be shown on this property.
+ .otherwise(([property]) => property)
+ );
+}
/**
* Transforms a backend PropertyDefinition (snake_case) to the frontend
diff --git a/apps/web/src/features/tasks-view/components/task-board-property.tsx b/apps/web/src/features/tasks-view/components/task-board-property.tsx
index 0db209c6f5..72aa89c6b0 100644
--- a/apps/web/src/features/tasks-view/components/task-board-property.tsx
+++ b/apps/web/src/features/tasks-view/components/task-board-property.tsx
@@ -58,76 +58,82 @@ export function TaskBoardProperty(props: {
iconOnly?: boolean;
onSave: PropertySaveFn;
}) {
- const isAssignee = () =>
- props.property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.ASSIGNEES;
- const isProject = () =>
- props.property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT;
- const isDate = () => props.property.valueType === 'DATE';
- const hasSelectIcon = () => getSelectValues(props.property).length > 0;
- const showProjectIcon = () =>
- props.iconOnly || getEntityValues(props.property).length !== 1;
-
return (
<Property.Root
property={props.property}
canEdit={props.canEdit}
onSave={props.onSave}
>
- <Property.Tooltip property={props.property}>
- <Property.Pill
- variant="ghost"
- aria-label={props.property.displayName}
- class={
- props.iconOnly
- ? 'min-h-6 min-w-6 justify-center p-0.5'
- : 'max-w-40 gap-1 px-1.5'
- }
- >
- <Switch
- fallback={
- <EmptyIcon class="size-3.5 shrink-0 text-ink-extra-muted" />
- }
- >
- <Match when={isAssignee()}>
- <Show
- when={getEntityValues(props.property).length}
- fallback={<UsersIcon class="size-3.5 shrink-0" />}
+ {(shown) => {
+ const isAssignee = () =>
+ shown().propertyDefinitionId === SYSTEM_PROPERTY_IDS.ASSIGNEES;
+ const isProject = () =>
+ shown().propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT;
+ const isDate = () => shown().valueType === 'DATE';
+ const hasSelectIcon = () => getSelectValues(shown()).length > 0;
+ const showProjectIcon = () =>
+ props.iconOnly || getEntityValues(shown()).length !== 1;
+
+ return (
+ <>
+ <Property.Tooltip property={shown()}>
+ <Property.Pill
+ variant="ghost"
+ aria-label={shown().displayName}
+ class={
+ props.iconOnly
+ ? 'min-h-6 min-w-6 justify-center p-0.5'
+ : 'max-w-40 gap-1 px-1.5'
+ }
>
- <Property.UserStack
- property={props.property}
- maxUsers={props.iconOnly ? 1 : 2}
- avatarClass="size-4"
- />
- </Show>
- </Match>
- <Match when={isProject()}>
- <Show when={showProjectIcon()}>
- <ProjectIcon class="size-3.5 shrink-0" />
- </Show>
- </Match>
- <Match when={isDate()}>
- <CalendarIcon class="size-3.5 shrink-0" />
- </Match>
- <Match when={hasSelectIcon()}>
- <Property.Icon
- property={props.property}
- class="size-3.5 shrink-0"
- />
- </Match>
- </Switch>
- <Show when={!props.iconOnly}>
- <Property.Text
- property={props.property}
- resolveSingleEntity={isProject()}
- class="min-w-0 truncate"
- fallback={<span>{props.property.displayName}</span>}
+ <Switch
+ fallback={
+ <EmptyIcon class="size-3.5 shrink-0 text-ink-extra-muted" />
+ }
+ >
+ <Match when={isAssignee()}>
+ <Show
+ when={getEntityValues(shown()).length}
+ fallback={<UsersIcon class="size-3.5 shrink-0" />}
+ >
+ <Property.UserStack
+ property={shown()}
+ maxUsers={props.iconOnly ? 1 : 2}
+ avatarClass="size-4"
+ />
+ </Show>
+ </Match>
+ <Match when={isProject()}>
+ <Show when={showProjectIcon()}>
+ <ProjectIcon class="size-3.5 shrink-0" />
+ </Show>
+ </Match>
+ <Match when={isDate()}>
+ <CalendarIcon class="size-3.5 shrink-0" />
+ </Match>
+ <Match when={hasSelectIcon()}>
+ <Property.Icon
+ property={shown()}
+ class="size-3.5 shrink-0"
+ />
+ </Match>
+ </Switch>
+ <Show when={!props.iconOnly}>
+ <Property.Text
+ property={shown()}
+ resolveSingleEntity={isProject()}
+ class="min-w-0 truncate"
+ fallback={<span>{shown().displayName}</span>}
+ />
+ </Show>
+ </Property.Pill>
+ </Property.Tooltip>
+ <Property.PopoverEditor
+ entitySelfFilter={{ entityType: 'TASK', blockId: props.taskId }}
/>
- </Show>
- </Property.Pill>
- </Property.Tooltip>
- <Property.PopoverEditor
- entitySelfFilter={{ entityType: 'TASK', blockId: props.taskId }}
- />
+ </>
+ );
+ }}
</Property.Root>
);
}
diff --git a/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx b/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx
index 0f57f3ab39..b276b51f8a 100644
--- a/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx
+++ b/apps/web/src/lib/core/component/TaskPreviewProperties.test.tsx
@@ -9,9 +9,12 @@ vi.mock('@property', () => ({
Property: {
Root: (props: {
canEdit: boolean;
- children: import('solid-js').JSX.Element;
+ property: Property;
+ children: (property: () => Property) => import('solid-js').JSX.Element;
}) => (
- <div data-status-editable={String(props.canEdit)}>{props.children}</div>
+ <div data-status-editable={String(props.canEdit)}>
+ {props.children(() => props.property)}
+ </div>
),
Tooltip: (props: { children: import('solid-js').JSX.Element }) =>
props.children,
diff --git a/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx b/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx
index 350512d00e..b99a0e79a1 100644
--- a/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx
+++ b/apps/web/src/lib/core/component/TaskPropertiesPreview.tsx
@@ -244,34 +244,39 @@ function TaskPropertiesPreviewContent(
property={property}
canEdit={props.canEdit}
onSave={saveHandler.saveProperty}
- onRefresh={props.refetch}
>
- <PropertyUI.Tooltip property={property}>
- <PropertyUI.EditTrigger
- class="inline-flex size-6 shrink-0 items-center justify-center rounded-full hover:bg-hover focus-visible:outline-2 focus-visible:outline-accent"
- aria-disabled={!props.canEdit || !!property.isMetadata}
- >
- <Show
- when={hasValue(property)}
- fallback={<CircleIcon class="size-4 text-ink-muted" />}
- >
- <PropertyUI.Icon property={property} class="size-4" />
- </Show>
- <span class="sr-only">
- Task status:{' '}
- <PropertyUI.Text
- property={property}
- fallback="Not started"
- />
- </span>
- </PropertyUI.EditTrigger>
- </PropertyUI.Tooltip>
- <PropertyUI.PopoverEditor
- entitySelfFilter={{
- entityType: 'TASK',
- blockId: props.taskId,
- }}
- />
+ {(shown) => (
+ <>
+ <PropertyUI.Tooltip property={shown()}>
+ <PropertyUI.EditTrigger
+ class="inline-flex size-6 shrink-0 items-center justify-center rounded-full hover:bg-hover focus-visible:outline-2 focus-visible:outline-accent"
+ aria-disabled={!props.canEdit || !!shown().isMetadata}
+ >
+ <Show
+ when={hasValue(shown())}
+ fallback={
+ <CircleIcon class="size-4 text-ink-muted" />
+ }
+ >
+ <PropertyUI.Icon property={shown()} class="size-4" />
+ </Show>
+ <span class="sr-only">
+ Task status:{' '}
+ <PropertyUI.Text
+ property={shown()}
+ fallback="Not started"
+ />
+ </span>
+ </PropertyUI.EditTrigger>
+ </PropertyUI.Tooltip>
+ <PropertyUI.PopoverEditor
+ entitySelfFilter={{
+ entityType: 'TASK',
+ blockId: props.taskId,
+ }}
+ />
+ </>
+ )}
</PropertyUI.Root>
)}
</For>