File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -67,14 +67,21 @@ impl<V: 'static> Flex<V> {
67
67
where
68
68
Tag : ' static ,
69
69
{
70
+ // Don't assume that this initialization is what scroll_state really is in other panes:
71
+ // `element_state` is shared and there could be init races.
70
72
let scroll_state = cx. element_state :: < Tag , Rc < ScrollState > > (
71
73
element_id,
72
74
Rc :: new ( ScrollState {
73
- scroll_to : Cell :: new ( scroll_to) ,
74
- scroll_position : Default :: default ( ) ,
75
75
type_tag : TypeTag :: new :: < Tag > ( ) ,
76
+ scroll_to : Default :: default ( ) ,
77
+ scroll_position : Default :: default ( ) ,
76
78
} ) ,
77
79
) ;
80
+ // Set scroll_to separately, because the default state is already picked as `None` by other panes
81
+ // by the time we start setting it here, hence update all others' state too.
82
+ scroll_state. update ( cx, |this, _| {
83
+ this. scroll_to . set ( scroll_to) ;
84
+ } ) ;
78
85
self . scroll_state = Some ( ( scroll_state, cx. handle ( ) . id ( ) ) ) ;
79
86
self
80
87
}
You can’t perform that action at this time.
0 commit comments