mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
fix: resolve RadioButtonSelect array bounds crash and auth dialog navigation (#46)
- Add bounds checking in RadioButtonSelect to prevent accessing undefined array elements - Add useEffect to ensure activeIndex stays within valid bounds when items array changes - Add validation guards around navigation handlers (up/down arrow keys) - Fix AuthDialog initialAuthIndex calculation to prevent negative values from findIndex - Ensure Enter key works properly on authentication screen Fixes TypeError: Cannot read properties of undefined (reading 'value') that occurred when activeIndex was out of bounds due to dynamic array changes or invalid initialization. Signed-off-by: loheagn <loheagn@icloud.com> Co-authored-by: linan.loheagn3 <linan.loheagn3@bytedance.com>
This commit is contained in:
@@ -47,7 +47,7 @@ export function AuthDialog({
|
||||
const [showOpenAIKeyPrompt, setShowOpenAIKeyPrompt] = useState(false);
|
||||
const items = [{ label: 'OpenAI', value: AuthType.USE_OPENAI }];
|
||||
|
||||
const initialAuthIndex = items.findIndex((item) => {
|
||||
const initialAuthIndex = Math.max(0, items.findIndex((item) => {
|
||||
if (settings.merged.selectedAuthType) {
|
||||
return item.value === settings.merged.selectedAuthType;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export function AuthDialog({
|
||||
}
|
||||
|
||||
return item.value === AuthType.LOGIN_WITH_GOOGLE;
|
||||
});
|
||||
}));
|
||||
|
||||
const handleAuthSelect = (authMethod: AuthType) => {
|
||||
const error = validateAuthMethod(authMethod);
|
||||
|
||||
Reference in New Issue
Block a user