@@ -56,7 +56,7 @@ const Sidebar = ({
56
56
} : SidebarProps ) => {
57
57
const [ theme , setTheme ] = useTheme ( ) ;
58
58
const [ showEnvVars , setShowEnvVars ] = useState ( false ) ;
59
- const [ shownEnvVars , setShownEnvVars ] = useState < Record < string , boolean > > ( { } ) ;
59
+ const [ shownEnvVars , setShownEnvVars ] = useState < Set < string > > ( new Set ( ) ) ;
60
60
61
61
return (
62
62
< div className = "w-80 bg-card border-r border-border flex flex-col h-full" >
@@ -149,8 +149,12 @@ const Sidebar = ({
149
149
newEnv [ newKey ] = value ;
150
150
setEnv ( newEnv ) ;
151
151
setShownEnvVars ( ( prev ) => {
152
- const { [ key ] : shown , ...rest } = prev ;
153
- return shown ? { ...rest , [ newKey ] : true } : rest ;
152
+ const next = new Set ( prev ) ;
153
+ if ( next . has ( key ) ) {
154
+ next . delete ( key ) ;
155
+ next . add ( newKey ) ;
156
+ }
157
+ return next ;
154
158
} ) ;
155
159
} }
156
160
className = "font-mono"
@@ -170,7 +174,7 @@ const Sidebar = ({
170
174
</ div >
171
175
< div className = "flex gap-2" >
172
176
< Input
173
- type = { shownEnvVars [ key ] ? "text" : "password" }
177
+ type = { shownEnvVars . has ( key ) ? "text" : "password" }
174
178
placeholder = "Value"
175
179
value = { value }
176
180
onChange = { ( e ) => {
@@ -185,16 +189,24 @@ const Sidebar = ({
185
189
size = "icon"
186
190
className = "h-9 w-9 p-0 shrink-0"
187
191
onClick = { ( ) => {
188
- setShownEnvVars ( ( prev ) => ( {
189
- ...prev ,
190
- [ key ] : ! prev [ key ] ,
191
- } ) ) ;
192
+ setShownEnvVars ( ( prev ) => {
193
+ const next = new Set ( prev ) ;
194
+ if ( next . has ( key ) ) {
195
+ next . delete ( key ) ;
196
+ } else {
197
+ next . add ( key ) ;
198
+ }
199
+ return next ;
200
+ } ) ;
192
201
} }
202
+ aria-label = { shownEnvVars . has ( key ) ? "Hide value" : "Show value" }
203
+ aria-pressed = { shownEnvVars . has ( key ) }
204
+ title = { shownEnvVars . has ( key ) ? "Hide value" : "Show value" }
193
205
>
194
- { shownEnvVars [ key ] ? (
195
- < Eye className = "h-4 w-4" />
206
+ { shownEnvVars . has ( key ) ? (
207
+ < Eye className = "h-4 w-4" aria-hidden = "true" />
196
208
) : (
197
- < EyeOff className = "h-4 w-4" />
209
+ < EyeOff className = "h-4 w-4" aria-hidden = "true" />
198
210
) }
199
211
</ Button >
200
212
</ div >
@@ -208,7 +220,6 @@ const Sidebar = ({
208
220
const newEnv = { ...env } ;
209
221
newEnv [ key ] = "" ;
210
222
setEnv ( newEnv ) ;
211
- setShownEnvVars ( { } ) ;
212
223
} }
213
224
>
214
225
Add Environment Variable
0 commit comments