@@ -36,10 +36,6 @@ type Props = {
36
36
linterContext : LinterContextProps ;
37
37
} ;
38
38
39
- type State = {
40
- focused : boolean ;
41
- showExamples : boolean ;
42
- } ;
43
39
// [LEMS-2411](Jan 2025) Third: This component has been moved to the NumericInput
44
40
// folder as we are actively working towards removing the InputNumber widget.
45
41
// This comment can be removed as part of LEMS-2411.
@@ -66,10 +62,7 @@ const InputWithExamples = forwardRef<
66
62
67
63
const context = React . useContext ( PerseusI18nContext ) ;
68
64
const inputRef = React . useRef < TextInput > ( null ) ;
69
- const [ state , setState ] = React . useState < State > ( {
70
- focused : false ,
71
- showExamples : false ,
72
- } ) ;
65
+ const [ inputFocused , setInputFocused ] = React . useState < boolean > ( false ) ;
73
66
74
67
useImperativeHandle ( ref , ( ) => ( {
75
68
current : inputRef . current ,
@@ -92,7 +85,7 @@ const InputWithExamples = forwardRef<
92
85
const _getInputClassName = ( ) => {
93
86
let inputClassName =
94
87
ApiClassNames . INPUT + " " + ApiClassNames . INTERACTIVE ;
95
- if ( state . focused ) {
88
+ if ( inputFocused ) {
96
89
inputClassName += " " + ApiClassNames . FOCUSED ;
97
90
}
98
91
if ( className ) {
@@ -148,18 +141,12 @@ const InputWithExamples = forwardRef<
148
141
149
142
const _handleFocus = ( ) => {
150
143
onFocus ( ) ;
151
- setState ( {
152
- focused : true ,
153
- showExamples : true ,
154
- } ) ;
144
+ setInputFocused ( true ) ;
155
145
} ;
156
146
157
147
const _handleBlur = ( ) => {
158
148
onBlur ( ) ;
159
- setState ( {
160
- focused : false ,
161
- showExamples : false ,
162
- } ) ;
149
+ setInputFocused ( false ) ;
163
150
} ;
164
151
165
152
// Display the examples as a string when there are less than or equal to 2 examples.
@@ -175,8 +162,8 @@ const InputWithExamples = forwardRef<
175
162
} )
176
163
. join ( "\n" ) ;
177
164
178
- // Display the examples when they are enabled (shouldShowExamples) and the input is focused (showExamples) .
179
- const showExamplesTooltip = shouldShowExamples && state . showExamples ;
165
+ // Display the examples when they are enabled (shouldShowExamples) and the input is focused.
166
+ const showExamplesTooltip = shouldShowExamples && inputFocused ;
180
167
181
168
return (
182
169
< Tooltip
0 commit comments