fix(Selector): Fix the issue with the Selector component being selected. (#7600)

* fix(Selector): update value comparison logic to use 'some' for selected values

* feat(ModelSettings): add ChevronDown icon as suffix for Select components
This commit is contained in:
Teo 2025-06-27 12:15:39 +08:00 committed by GitHub
parent 46de46965f
commit 093d04c386
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -70,7 +70,7 @@ const Selector = <V extends string | number>({
const findLabels = (opts: SelectorOption<V>[]): (string | ReactNode)[] => {
const labels: (string | ReactNode)[] = []
for (const opt of opts) {
if (selectedValues.includes(opt.value)) {
if (selectedValues.some((v) => v == opt.value)) {
labels.push(opt.label)
}
if (opt.options) {
@ -91,7 +91,7 @@ const Selector = <V extends string | number>({
const mapOption = (option: SelectorOption<V>) => ({
key: option.value,
label: option.label,
extra: <CheckIcon>{selectedValues.includes(option.value) && <Check size={14} />}</CheckIcon>,
extra: <CheckIcon>{selectedValues.some((v) => v == option.value) && <Check size={14} />}</CheckIcon>,
disabled: option.disabled,
type: option.type || (option.options ? 'group' : undefined),
children: option.options?.map(mapOption)

View File

@ -16,7 +16,7 @@ import { setTranslateModelPrompt } from '@renderer/store/settings'
import { Model } from '@renderer/types'
import { Button, Select, Tooltip } from 'antd'
import { find, sortBy } from 'lodash'
import { CircleHelp, FolderPen, Languages, MessageSquareMore, Rocket, Settings2 } from 'lucide-react'
import { ChevronDown, CircleHelp, FolderPen, Languages, MessageSquareMore, Rocket, Settings2 } from 'lucide-react'
import { FC, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
@ -104,6 +104,7 @@ const ModelSettings: FC = () => {
options={selectOptions}
showSearch
placeholder={t('settings.models.empty')}
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}
/>
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={DefaultAssistantSettings.show} />
</HStack>
@ -125,6 +126,7 @@ const ModelSettings: FC = () => {
options={selectOptions}
showSearch
placeholder={t('settings.models.empty')}
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}
/>
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={TopicNamingModalPopup.show} />
</HStack>
@ -146,6 +148,7 @@ const ModelSettings: FC = () => {
options={selectOptions}
showSearch
placeholder={t('settings.models.empty')}
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}
/>
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={onUpdateTranslateModel} />
{translateModelPrompt !== TRANSLATE_PROMPT && (
@ -191,7 +194,8 @@ const ModelSettings: FC = () => {
value={quickAssistantId || defaultAssistant.id}
style={{ width: 360 }}
onChange={(value) => dispatch(setQuickAssistantId(value))}
placeholder={t('settings.models.quick_assistant_selection')}>
placeholder={t('settings.models.quick_assistant_selection')}
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}>
<Select.Option key={defaultAssistant.id} value={defaultAssistant.id}>
<AssistantItem>
<ModelAvatar model={defaultAssistant.model || defaultModel} size={18} />