fix(custom-widgets): show edit-mode placeholder instead of definition not found
When a custom widget is added to a board in edit mode, the item only exists in local TanStack cache (persisted on saveBoard at edit-mode exit). The getData query fired immediately, hit the DB before the item existed, threw NOT_FOUND, and retry was disabled so the widget stayed on 'definition not found' until reload. - Gate getData with !isEditMode so it only fires for persisted items - Show an edit-mode placeholder instead of an empty box - Add e2e regression test verifying no 'not found' before reload
This commit is contained in:
1 parent
9c31cdce37
commit
69788124c1
2 files changed
+80
-2
No files matched your search
@@ -129,7 +129,7 @@ function CustomApiWidgetInner({
|
||||
const { data, isLoading, error } = clientApi.widget.customApi.getData.useQuery(
|
||||
{ itemId: itemId ?? "" },
|
||||
{
|
||||
enabled: Boolean(itemId),
|
||||
enabled: Boolean(itemId) && !isEditMode,
|
||||
refetchInterval: (query) => {
|
||||
const result = query.state.data as Record<string, unknown> | undefined;
|
||||
if (
|
||||
@@ -170,7 +170,18 @@ function CustomApiWidgetInner({
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) return null;
|
||||
if (!data) {
|
||||
if (isEditMode) {
|
||||
return (
|
||||
<Center h="100%">
|
||||
<Text c="dimmed" size="sm" ta="center">
|
||||
{t("editModePending")}
|
||||
</Text>
|
||||
</Center>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const widgetData = data as Record<string, unknown>;
|
||||
const dataType = widgetData.type as string | undefined;
|
||||
|
||||
Reference in new issue
Block a user