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> {
6767 where
6868 Tag : ' static ,
6969 {
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.
7072 let scroll_state = cx. element_state :: < Tag , Rc < ScrollState > > (
7173 element_id,
7274 Rc :: new ( ScrollState {
73- scroll_to : Cell :: new ( scroll_to) ,
74- scroll_position : Default :: default ( ) ,
7575 type_tag : TypeTag :: new :: < Tag > ( ) ,
76+ scroll_to : Default :: default ( ) ,
77+ scroll_position : Default :: default ( ) ,
7678 } ) ,
7779 ) ;
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+ } ) ;
7885 self . scroll_state = Some ( ( scroll_state, cx. handle ( ) . id ( ) ) ) ;
7986 self
8087 }
You can’t perform that action at this time.
0 commit comments