mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(panel): stop the task status dropdown duplicating the current status
The status Select always renders the current status as its first item, then
appends the valid-transitions list. When a task changed state (e.g. on
approve-and-merge to completed) the cached valid-transitions query was not
refetched, so it still held the previous state's targets — which include the
now-current status. That yields two SelectItems with the same value; Radix
requires unique values, so the list showed a duplicate entry and the trigger
label rendered doubled ("Completed Completed").
Key the valid-transitions query on the task status so it refetches on every
state change, and filter the current status out of the appended list so it can
never duplicate the always-rendered current item.
This commit is contained in:
@@ -97,8 +97,14 @@ export function TaskHeader({ task, onAction }: TaskHeaderProps) {
|
||||
const updateTask = useUpdateTask();
|
||||
// Fetch valid next statuses from GET /tasks/{id}/valid-transitions.
|
||||
// Falls back to [] while loading or on error — the Select is disabled during loading.
|
||||
const { data: validTransitionsData, isLoading: isTransitionsLoading } = useTaskValidTransitions(task.id);
|
||||
const nextStatuses: TaskStatus[] = validTransitionsData ?? [];
|
||||
const { data: validTransitionsData, isLoading: isTransitionsLoading } = useTaskValidTransitions(task.id, task.status);
|
||||
// Exclude the current status: it is always rendered first (below), so a stale
|
||||
// cache or a backend list that re-includes it would duplicate the item. Radix
|
||||
// Select requires unique item values, so a duplicate also garbles the trigger
|
||||
// label (it renders as e.g. "Completed Completed").
|
||||
const nextStatuses: TaskStatus[] = (validTransitionsData ?? []).filter(
|
||||
(s) => s !== task.status
|
||||
);
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
// Inline editing states
|
||||
|
||||
Reference in New Issue
Block a user