File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -116,12 +116,19 @@ struct CandidateBarView: View {
116116 }
117117 Spacer ( )
118118 } . frame (
119- height: barHeightExcludePreedit)
119+ height: barHeightExcludePreedit
120+ )
121+ // Force re-render, otherwise scrolling to the first candidate may fail due to the first isn't rendered.
122+ . id ( batch)
120123 } . scrollIndicators ( . hidden) // Hide scroll bar as native keyboard.
121124 . padding ( [ . leading] , columnGap / 2 )
122- . onChange ( of: batch) { _ in
123- // Use batch instead of candidates because we don't want to reset on loading more.
124- proxy. scrollTo ( 0 , anchor: . leading)
125+ . onChange ( of: [ batch, highlighted] ) { newValues in
126+ // Watch batch instead of candidates because we don't want to reset on loading more.
127+ let newHighlighted = newValues [ 1 ]
128+ // Test in mozc by typing mizu and space through all candidates.
129+ proxy. scrollTo (
130+ newHighlighted,
131+ anchor: newHighlighted == candidates. count - 1 ? . leading : . trailing)
125132 }
126133 }
127134 }
You can’t perform that action at this time.
0 commit comments