@@ -56,7 +56,7 @@ const Sidebar = ({
5656} : SidebarProps ) => {
5757 const [ theme , setTheme ] = useTheme ( ) ;
5858 const [ showEnvVars , setShowEnvVars ] = useState ( false ) ;
59- const [ shownEnvVars , setShownEnvVars ] = useState < Record < string , boolean > > ( { } ) ;
59+ const [ shownEnvVars , setShownEnvVars ] = useState < Set < string > > ( new Set ( ) ) ;
6060
6161 return (
6262 < div className = "w-80 bg-card border-r border-border flex flex-col h-full" >
@@ -149,8 +149,12 @@ const Sidebar = ({
149149 newEnv [ newKey ] = value ;
150150 setEnv ( newEnv ) ;
151151 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 ;
154158 } ) ;
155159 } }
156160 className = "font-mono"
@@ -170,7 +174,7 @@ const Sidebar = ({
170174 </ div >
171175 < div className = "flex gap-2" >
172176 < Input
173- type = { shownEnvVars [ key ] ? "text" : "password" }
177+ type = { shownEnvVars . has ( key ) ? "text" : "password" }
174178 placeholder = "Value"
175179 value = { value }
176180 onChange = { ( e ) => {
@@ -185,16 +189,24 @@ const Sidebar = ({
185189 size = "icon"
186190 className = "h-9 w-9 p-0 shrink-0"
187191 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+ } ) ;
192201 } }
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" }
193205 >
194- { shownEnvVars [ key ] ? (
195- < Eye className = "h-4 w-4" />
206+ { shownEnvVars . has ( key ) ? (
207+ < Eye className = "h-4 w-4" aria-hidden = "true" />
196208 ) : (
197- < EyeOff className = "h-4 w-4" />
209+ < EyeOff className = "h-4 w-4" aria-hidden = "true" />
198210 ) }
199211 </ Button >
200212 </ div >
@@ -208,7 +220,6 @@ const Sidebar = ({
208220 const newEnv = { ...env } ;
209221 newEnv [ key ] = "" ;
210222 setEnv ( newEnv ) ;
211- setShownEnvVars ( { } ) ;
212223 } }
213224 >
214225 Add Environment Variable
0 commit comments