@@ -118,6 +118,15 @@ pub fn name_component(props: &NameProps) -> Html {
118
118
}
119
119
) ) ;
120
120
121
+ use_effect_with (
122
+ popup. clone ( ) ,
123
+ cloned ! ( new_name, name; move |popup| {
124
+ if * * popup {
125
+ new_name. set( name. clone( ) ) ;
126
+ }
127
+ } ) ,
128
+ ) ;
129
+
121
130
html ! {
122
131
<div class={ classes!( "name" , "anchor" ) } onclick={ cloned!( popup; move |_| if !* popup { popup. set( true ) } ) } >
123
132
{ & props. name }
@@ -330,10 +339,16 @@ pub fn branch_kind_component(props: &BranchProps) -> Html {
330
339
331
340
let top_frac = use_state ( || props. kind . choice_frac ( ) . 0 ) ;
332
341
let bottom_frac = use_state ( || props. kind . choice_frac ( ) . 1 ) ;
333
- let top_input = Callback :: from ( cloned ! ( top_frac;
334
- move |e: InputEvent | top_frac. set( e. target_unchecked_into:: <HtmlInputElement >( ) . value_as_number( ) as f32 ) ) ) ;
335
- let bottom_input = Callback :: from ( cloned ! ( bottom_frac;
336
- move |e: InputEvent | bottom_frac. set( e. target_unchecked_into:: <HtmlInputElement >( ) . value_as_number( ) as f32 ) ) ) ;
342
+ let top_input = Callback :: from ( cloned ! ( top_frac; move |e: InputEvent | {
343
+ if let Ok ( f) = e. target_unchecked_into:: <HtmlInputElement >( ) . value( ) . parse:: <f32 >( ) {
344
+ top_frac. set( f) ;
345
+ }
346
+ } ) ) ;
347
+ let bottom_input = Callback :: from ( cloned ! ( bottom_frac; move |e: InputEvent | {
348
+ if let Ok ( f) = e. target_unchecked_into:: <HtmlInputElement >( ) . value( ) . parse:: <f32 >( ) {
349
+ bottom_frac. set( f) ;
350
+ }
351
+ } ) ) ;
337
352
let frac_submit = Callback :: from (
338
353
cloned ! ( popup, on_change, top, bottom, top_frac, bottom_frac, ctx;
339
354
move |e: SubmitEvent | {
@@ -343,6 +358,17 @@ pub fn branch_kind_component(props: &BranchProps) -> Html {
343
358
} ) ,
344
359
) ;
345
360
361
+ let choices = props. kind . choice_frac ( ) ;
362
+ use_effect_with (
363
+ popup. clone ( ) ,
364
+ cloned ! ( top_frac, bottom_frac; move |popup| {
365
+ if * * popup {
366
+ top_frac. set( choices. 0 ) ;
367
+ bottom_frac. set( choices. 1 ) ;
368
+ }
369
+ } ) ,
370
+ ) ;
371
+
346
372
let abstract_name = use_state ( || "" . to_string ( ) ) ;
347
373
let abstract_input = Callback :: from ( cloned ! ( abstract_name;
348
374
move |e: InputEvent | abstract_name. set( e. target_unchecked_into:: <HtmlInputElement >( ) . value( ) ) ) ) ;
0 commit comments