fix(SettingDialog): use `value` instead of `selected` props in <select>

avoid the browser console warning in devServer mode
This commit is contained in:
WanQuanXie 2024-05-07 06:35:39 +08:00
parent f88f179920
commit 01fc683d32
1 changed files with 10 additions and 26 deletions

View File

@ -170,6 +170,7 @@ const SettingsDialog = ({
Chat model Provider Chat model Provider
</p> </p>
<select <select
value={selectedChatModelProvider ?? undefined}
onChange={(e) => { onChange={(e) => {
setSelectedChatModelProvider(e.target.value); setSelectedChatModelProvider(e.target.value);
setSelectedChatModel( setSelectedChatModel(
@ -180,13 +181,7 @@ const SettingsDialog = ({
> >
{Object.keys(config.chatModelProviders).map( {Object.keys(config.chatModelProviders).map(
(provider) => ( (provider) => (
<option <option key={provider} value={provider}>
key={provider}
value={provider}
selected={
provider === selectedChatModelProvider
}
>
{provider.charAt(0).toUpperCase() + {provider.charAt(0).toUpperCase() +
provider.slice(1)} provider.slice(1)}
</option> </option>
@ -200,6 +195,7 @@ const SettingsDialog = ({
<div className="flex flex-col space-y-1"> <div className="flex flex-col space-y-1">
<p className="text-white/70 text-sm">Chat Model</p> <p className="text-white/70 text-sm">Chat Model</p>
<select <select
value={selectedChatModel ?? undefined}
onChange={(e) => onChange={(e) =>
setSelectedChatModel(e.target.value) setSelectedChatModel(e.target.value)
} }
@ -214,21 +210,17 @@ const SettingsDialog = ({
config.chatModelProviders[ config.chatModelProviders[
selectedChatModelProvider selectedChatModelProvider
].map((model) => ( ].map((model) => (
<option <option key={model} value={model}>
key={model}
value={model}
selected={model === selectedChatModel}
>
{model} {model}
</option> </option>
)) ))
) : ( ) : (
<option value="" disabled selected> <option value="" disabled>
No models available No models available
</option> </option>
) )
) : ( ) : (
<option value="" disabled selected> <option value="" disabled>
Invalid provider, please check backend logs Invalid provider, please check backend logs
</option> </option>
)} )}
@ -287,6 +279,7 @@ const SettingsDialog = ({
Embedding model Provider Embedding model Provider
</p> </p>
<select <select
value={selectedEmbeddingModelProvider ?? undefined}
onChange={(e) => { onChange={(e) => {
setSelectedEmbeddingModelProvider(e.target.value); setSelectedEmbeddingModelProvider(e.target.value);
setSelectedEmbeddingModel( setSelectedEmbeddingModel(
@ -297,13 +290,7 @@ const SettingsDialog = ({
> >
{Object.keys(config.embeddingModelProviders).map( {Object.keys(config.embeddingModelProviders).map(
(provider) => ( (provider) => (
<option <option key={provider} value={provider}>
key={provider}
value={provider}
selected={
provider === selectedEmbeddingModelProvider
}
>
{provider.charAt(0).toUpperCase() + {provider.charAt(0).toUpperCase() +
provider.slice(1)} provider.slice(1)}
</option> </option>
@ -316,6 +303,7 @@ const SettingsDialog = ({
<div className="flex flex-col space-y-1"> <div className="flex flex-col space-y-1">
<p className="text-white/70 text-sm">Embedding Model</p> <p className="text-white/70 text-sm">Embedding Model</p>
<select <select
value={selectedEmbeddingModel ?? undefined}
onChange={(e) => onChange={(e) =>
setSelectedEmbeddingModel(e.target.value) setSelectedEmbeddingModel(e.target.value)
} }
@ -330,11 +318,7 @@ const SettingsDialog = ({
config.embeddingModelProviders[ config.embeddingModelProviders[
selectedEmbeddingModelProvider selectedEmbeddingModelProvider
].map((model) => ( ].map((model) => (
<option <option key={model} value={model}>
key={model}
value={model}
selected={model === selectedEmbeddingModel}
>
{model} {model}
</option> </option>
)) ))