Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(FeedbackFilterSelect): update filter options to include new status values

Steven Enamakele59ea14f7ddd
diff --git a/app/src/components/feedback/FeedbackFilterSelect.tsx b/app/src/components/feedback/FeedbackFilterSelect.tsx
index 1e0ea37ae2..474a16a3f9 100644
--- a/app/src/components/feedback/FeedbackFilterSelect.tsx
+++ b/app/src/components/feedback/FeedbackFilterSelect.tsx
@@ -1,6 +1,4 @@
-import { useEffect, useId, useRef, useState } from 'react';
-
-import { Button } from '../ui';
+import { SelectContent, SelectItem, SelectRoot, SelectTrigger, SelectValue } from '../ui';
interface FilterOption {
value: string;
@@ -16,14 +14,13 @@ interface FeedbackFilterSelectProps {
}
/**
- * Lightweight styled dropdown for the board filters. Native `<select>` is hard
- * to theme consistently across platforms, so this renders a button + popover
- * with the app's tokens. It honours the listbox ARIA contract: the open popover
- * takes focus and tracks a highlighted option via `aria-activedescendant`, with
- * Up/Down/Home/End to move, Enter/Space to select, Escape + outside-click to
- * dismiss. Keeping focus on the listbox (rather than roving it across option
- * buttons) means every keystroke lands on one handler regardless of how the
- * popover was opened.
+ * Styled dropdown for the board filters. A short (<= ~20 option), single-line
+ * list that needs no custom item rendering beyond Radix's built-in selected
+ * checkmark — the case `Select.tsx`'s doc comment calls out as the right fit
+ * for Radix `Select` over `NativeSelect`. Radix owns the listbox ARIA
+ * contract (roving focus, typeahead, Home/End, Enter/Space, Escape,
+ * outside-click dismissal, focus return to the trigger) so this component
+ * only wires options to items.
*/
export default function FeedbackFilterSelect({
value,
@@ -31,165 +28,18 @@ export default function FeedbackFilterSelect({
onChange,
ariaLabel,
}: FeedbackFilterSelectProps) {
- const [open, setOpen] = useState(false);
- const [activeIndex, setActiveIndex] = useState(-1);
- const rootRef = useRef<HTMLDivElement>(null);
- const triggerRef = useRef<HTMLButtonElement>(null);
- const listRef = useRef<HTMLUListElement>(null);
- const baseId = useId();
- const optionId = (index: number) => `${baseId}-option-${index}`;
-
- const selectedIndex = Math.max(
- 0,
- options.findIndex(option => option.value === value)
- );
-
- const openMenu = () => {
- setActiveIndex(selectedIndex);
- setOpen(true);
- };
-
- const closeMenu = (focusTrigger = false) => {
- setOpen(false);
- if (focusTrigger) triggerRef.current?.focus();
- };
-
- const selectOption = (option: FilterOption) => {
- onChange(option.value);
- closeMenu(true);
- };
-
- // Dismiss on outside-click or Escape while the popover is open.
- useEffect(() => {
- if (!open) return undefined;
- const onPointerDown = (event: MouseEvent) => {
- if (rootRef.current && !rootRef.current.contains(event.target as Node)) setOpen(false);
- };
- const onKeyDown = (event: KeyboardEvent) => {
- if (event.key === 'Escape') closeMenu(true);
- };
- document.addEventListener('mousedown', onPointerDown);
- document.addEventListener('keydown', onKeyDown);
- return () => {
- document.removeEventListener('mousedown', onPointerDown);
- document.removeEventListener('keydown', onKeyDown);
- };
- }, [open]);
-
- // Move focus into the popover when it opens so keystrokes target the listbox.
- useEffect(() => {
- if (open) listRef.current?.focus();
- }, [open]);
-
- const onTriggerKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {
- if (!open && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
- event.preventDefault();
- openMenu();
- }
- };
-
- const onListKeyDown = (event: React.KeyboardEvent<HTMLUListElement>) => {
- switch (event.key) {
- case 'ArrowDown':
- event.preventDefault();
- setActiveIndex(index => (index + 1) % options.length);
- break;
- case 'ArrowUp':
- event.preventDefault();
- setActiveIndex(index => (index - 1 + options.length) % options.length);
- break;
- case 'Home':
- event.preventDefault();
- setActiveIndex(0);
- break;
- case 'End':
- event.preventDefault();
- setActiveIndex(options.length - 1);
- break;
- case 'Enter':
- case ' ':
- event.preventDefault();
- if (activeIndex >= 0) selectOption(options[activeIndex]);
- break;
- case 'Escape':
- event.preventDefault();
- closeMenu(true);
- break;
- default:
- break;
- }
- };
-
- const current = options.find(option => option.value === value) ?? options[0];
-
return (
- <div ref={rootRef} className="relative">
- <Button
- ref={triggerRef}
- variant="secondary"
- size="sm"
- aria-haspopup="listbox"
- aria-expanded={open}
- aria-label={ariaLabel}
- onClick={() => (open ? closeMenu() : openMenu())}
- onKeyDown={onTriggerKeyDown}
- className={`gap-1.5 text-xs font-medium ${
- open ? 'border-primary-500/50 ring-2 ring-primary-500/20' : ''
- }`}>
- {current?.label}
- <svg
- className={`h-3.5 w-3.5 transition-transform ${open ? 'rotate-180' : ''}`}
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
- </svg>
- </Button>
-
- {open && (
- <ul
- ref={listRef}
- role="listbox"
- tabIndex={-1}
- aria-label={ariaLabel}
- aria-activedescendant={activeIndex >= 0 ? optionId(activeIndex) : undefined}
- onKeyDown={onListKeyDown}
- className="absolute z-20 mt-1.5 min-w-[10rem] animate-scale-in overflow-hidden rounded-xl border border-line bg-surface p-1 shadow-medium focus:outline-none dark:border-line-strong">
- {options.map((option, index) => {
- const selected = option.value === value;
- const active = index === activeIndex;
- return (
- <li key={option.value} id={optionId(index)} role="option" aria-selected={selected}>
- <Button
- variant="tertiary"
- size="sm"
- tabIndex={-1}
- onClick={() => selectOption(option)}
- onMouseEnter={() => setActiveIndex(index)}
- className={`w-full justify-between gap-3 text-left text-xs font-normal hover:bg-surface-subtle ${
- selected ? 'font-medium text-primary-600 dark:text-primary-400' : 'text-content-secondary'
- } ${active ? 'bg-surface-subtle' : selected ? 'bg-primary-500/10' : ''}`}>
- {option.label}
- {selected && (
- <svg
- className="h-3.5 w-3.5"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24">
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2.2}
- d="M5 13l4 4L19 7"
- />
- </svg>
- )}
- </Button>
- </li>
- );
- })}
- </ul>
- )}
- </div>
+ <SelectRoot value={value} onValueChange={onChange}>
+ <SelectTrigger aria-label={ariaLabel} inputSize="sm" className="w-auto gap-1.5 text-xs font-medium">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent align="end">
+ {options.map(option => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </SelectRoot>
);
}