@@ -59,60 +59,23 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
5959 }
6060 } , [ props . edit_format_instructions ] )
6161
62- useEffect ( ( ) => {
63- const handler = setTimeout ( ( ) => {
64- const num_threshold = parseInt ( context_size_warning_threshold , 10 )
65- if (
66- ! isNaN ( num_threshold ) &&
67- num_threshold >= 0 &&
68- props . context_size_warning_threshold !== undefined &&
69- num_threshold != props . context_size_warning_threshold
70- ) {
71- props . on_context_size_warning_threshold_change ( num_threshold )
72- }
73- } , 500 )
74- return ( ) => clearTimeout ( handler )
75- } , [
76- context_size_warning_threshold ,
77- props . on_context_size_warning_threshold_change ,
78- props . context_size_warning_threshold
79- ] )
62+ const handle_context_size_warning_threshold_blur = ( ) => {
63+ const num_threshold = parseInt ( context_size_warning_threshold , 10 )
64+ if ( ! isNaN ( num_threshold ) && num_threshold >= 0 ) {
65+ props . on_context_size_warning_threshold_change ( num_threshold )
66+ }
67+ }
8068
81- useEffect ( ( ) => {
82- const handler = setTimeout ( ( ) => {
83- const num_hours = parseInt ( checkpoint_lifespan_str , 10 )
84- if (
85- ! isNaN ( num_hours ) &&
86- num_hours > 0 &&
87- props . checkpoint_lifespan !== undefined &&
88- num_hours != props . checkpoint_lifespan
89- ) {
90- props . on_checkpoint_lifespan_change ( num_hours )
91- }
92- } , 500 )
93- return ( ) => clearTimeout ( handler )
94- } , [
95- checkpoint_lifespan_str ,
96- props . on_checkpoint_lifespan_change ,
97- props . checkpoint_lifespan
98- ] )
69+ const handle_checkpoint_lifespan_blur = ( ) => {
70+ const num_hours = parseInt ( checkpoint_lifespan_str , 10 )
71+ if ( ! isNaN ( num_hours ) && num_hours > 0 ) {
72+ props . on_checkpoint_lifespan_change ( num_hours )
73+ }
74+ }
9975
100- useEffect ( ( ) => {
101- const handler = setTimeout ( ( ) => {
102- if (
103- props . edit_format_instructions &&
104- JSON . stringify ( instructions ) !==
105- JSON . stringify ( props . edit_format_instructions )
106- ) {
107- props . on_edit_format_instructions_change ( instructions )
108- }
109- } , 500 )
110- return ( ) => clearTimeout ( handler )
111- } , [
112- instructions ,
113- props . on_edit_format_instructions_change ,
114- props . edit_format_instructions
115- ] )
76+ const handle_instructions_blur = ( ) => {
77+ props . on_edit_format_instructions_change ( instructions )
78+ }
11679
11780 return (
11881 < Section
@@ -139,6 +102,7 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
139102 type = "number"
140103 value = { context_size_warning_threshold }
141104 on_change = { set_context_size_warning_threshold }
105+ on_blur = { handle_context_size_warning_threshold_blur }
142106 max_width = { 100 }
143107 />
144108 }
@@ -151,6 +115,7 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
151115 type = "number"
152116 value = { checkpoint_lifespan_str }
153117 on_change = { set_checkpoint_lifespan_str }
118+ on_blur = { handle_checkpoint_lifespan_blur }
154119 max_width = { 100 }
155120 min = { 1 }
156121 />
@@ -179,6 +144,7 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
179144 on_change = { ( value ) =>
180145 set_instructions ( ( prev ) => ( { ...prev , whole : value } ) )
181146 }
147+ on_blur = { handle_instructions_blur }
182148 />
183149 }
184150 />
@@ -192,6 +158,7 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
192158 on_change = { ( value ) =>
193159 set_instructions ( ( prev ) => ( { ...prev , truncated : value } ) )
194160 }
161+ on_blur = { handle_instructions_blur }
195162 />
196163 }
197164 />
@@ -205,6 +172,7 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
205172 on_change = { ( value ) =>
206173 set_instructions ( ( prev ) => ( { ...prev , diff : value } ) )
207174 }
175+ on_blur = { handle_instructions_blur }
208176 />
209177 }
210178 />
0 commit comments