fix: disallow empty selection in Select component

(cherry picked from commit 48eef556770030d8a032fb6dd0e6888d1f0750a0)
This commit is contained in:
miwu04 2025-04-30 01:47:43 +08:00 committed by ezequielnick
parent f54ffcf42b
commit 511eb0c7fa
4 changed files with 9 additions and 1 deletions

View File

@ -193,6 +193,7 @@ const GeneralConfig: React.FC = () => {
selectionMode="multiple"
selectedKeys={new Set(envType)}
aria-label={t('settings.envType')}
disallowEmptySelection={true}
onSelectionChange={async (v) => {
try {
await patchAppConfig({
@ -389,6 +390,7 @@ const GeneralConfig: React.FC = () => {
size="sm"
selectedKeys={new Set([customTheme])}
aria-label={t('settings.selectTheme')}
disallowEmptySelection={true}
onSelectionChange={async (v) => {
try {
await patchAppConfig({ customTheme: v.currentKey as string })

View File

@ -129,6 +129,7 @@ const MihomoConfig: React.FC = () => {
size="sm"
selectedKeys={new Set([proxyCols])}
aria-label={t('mihomo.proxyColumns.title')}
disallowEmptySelection={true}
onSelectionChange={async (v) => {
await patchAppConfig({ proxyCols: v.currentKey as 'auto' | '1' | '2' | '3' | '4' })
}}
@ -147,6 +148,7 @@ const MihomoConfig: React.FC = () => {
className="w-[150px]"
size="sm"
selectedKeys={new Set([mihomoCpuPriority])}
disallowEmptySelection={true}
onSelectionChange={async (v) => {
try {
await patchAppConfig({

View File

@ -236,6 +236,7 @@ const Connections: React.FC = () => {
className="w-[180px] min-w-[131px]"
aria-label={t('connections.orderBy')}
selectedKeys={new Set([connectionOrderBy])}
disallowEmptySelection={true}
onSelectionChange={async (v) => {
await patchAppConfig({
connectionOrderBy: v.currentKey as

View File

@ -27,7 +27,7 @@ const CoreMap = {
const Mihomo: React.FC = () => {
const { t } = useTranslation()
const { appConfig, patchAppConfig } = useAppConfig()
const {
const {
core = 'mihomo',
maxLogDays = 7,
sysProxy,
@ -136,6 +136,7 @@ const Mihomo: React.FC = () => {
size="sm"
aria-label={t('mihomo.selectCoreVersion')}
selectedKeys={new Set([core])}
disallowEmptySelection={true}
onSelectionChange={async (v) => {
handleConfigChangeWithRestart('core', v.currentKey as 'mihomo' | 'mihomo-alpha')
}}
@ -702,6 +703,7 @@ const Mihomo: React.FC = () => {
size="sm"
aria-label={t('mihomo.selectLogLevel')}
selectedKeys={new Set([logLevel])}
disallowEmptySelection={true}
onSelectionChange={(v) => {
onChangeNeedRestart({ 'log-level': v.currentKey as LogLevel })
}}
@ -720,6 +722,7 @@ const Mihomo: React.FC = () => {
size="sm"
aria-label={t('mihomo.selectFindProcessMode')}
selectedKeys={new Set([findProcessMode])}
disallowEmptySelection={true}
onSelectionChange={(v) => {
onChangeNeedRestart({ 'find-process-mode': v.currentKey as FindProcessMode })
}}