@@ -112,6 +112,8 @@ const KeyboardAwareScrollView = forwardRef<
112
112
const scrollBeforeKeyboardMovement = useSharedValue ( 0 ) ;
113
113
const { input } = useReanimatedFocusedInput ( ) ;
114
114
const layout = useSharedValue < FocusedInputLayoutChangedEvent | null > ( null ) ;
115
+ const lastSelection =
116
+ useSharedValue < FocusedInputSelectionChangedEvent | null > ( null ) ;
115
117
116
118
const { height } = useWindowDimensions ( ) ;
117
119
@@ -154,9 +156,13 @@ const KeyboardAwareScrollView = forwardRef<
154
156
const inputHeight = layout . value ?. layout . height || 0 ;
155
157
const point = absoluteY + inputHeight ;
156
158
159
+ console . log ( { absoluteY, inputHeight, point, visibleRect } ) ;
160
+
157
161
if ( visibleRect - point <= bottomOffset ) {
158
162
const relativeScrollTo =
159
163
keyboardHeight . value - ( height - point ) + bottomOffset ;
164
+
165
+ console . log ( { relativeScrollTo } ) ;
160
166
const interpolatedScrollTo = interpolate (
161
167
e ,
162
168
[ initialKeyboardSize . value , keyboardHeight . value ] ,
@@ -171,6 +177,11 @@ const KeyboardAwareScrollView = forwardRef<
171
177
const targetScrollY =
172
178
Math . max ( interpolatedScrollTo , 0 ) + scrollPosition . value ;
173
179
180
+ console . log ( {
181
+ targetScrollY,
182
+ scrollPosition : scrollPosition . value ,
183
+ interpolatedScrollTo,
184
+ } ) ;
174
185
scrollTo ( scrollViewAnimatedRef , 0 , targetScrollY , animated ) ;
175
186
176
187
return interpolatedScrollTo ;
@@ -260,6 +271,15 @@ const KeyboardAwareScrollView = forwardRef<
260
271
( e : FocusedInputSelectionChangedEvent ) => {
261
272
"worklet" ;
262
273
274
+ const lastTarget = lastSelection . value ?. target ;
275
+
276
+ lastSelection . value = e ;
277
+
278
+ if ( e . target !== lastTarget ) {
279
+ // ignore this event, because "focus changed" event handled in `useSmoothKeyboardHandler`
280
+ return ;
281
+ }
282
+
263
283
console . log ( e ) ;
264
284
265
285
if ( e . selection . start . position !== e . selection . end . position ) {
0 commit comments