🎯 fix: Prevent UI De-sync By Removing Redundant States (#5333)

* fix: remove local state from Dropdown causing de-sync

* refactor: cleanup STT code, avoid redundant states to prevent de-sync and side effects

* fix: reset transcript after sending final text to prevent data loss

* fix: clear timeout on component unmount to prevent memory leaks
This commit is contained in:
Danny Avila 2025-01-16 17:38:59 -05:00 committed by GitHub
parent b55e695541
commit e309c6abef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 149 additions and 145 deletions

View file

@ -1,10 +1,10 @@
import React, { useState } from 'react';
import React from 'react';
import * as Select from '@ariakit/react/select';
import type { Option } from '~/common';
import { cn } from '~/utils/';
interface DropdownProps {
value: string;
value?: string;
label?: string;
onChange: (value: string) => void;
options: string[] | Option[];
@ -14,7 +14,7 @@ interface DropdownProps {
}
const Dropdown: React.FC<DropdownProps> = ({
value: initialValue,
value: selectedValue,
label = '',
onChange,
options,
@ -22,10 +22,7 @@ const Dropdown: React.FC<DropdownProps> = ({
sizeClasses,
testId = 'dropdown-menu',
}) => {
const [selectedValue, setSelectedValue] = useState(initialValue);
const handleChange = (value: string) => {
setSelectedValue(value);
onChange(value);
};