Commit 5efd60f
fix: use measureInWindow for correct KAV positioning in modals
KeyboardAvoidingView uses onLayout to get the view's frame, but
onLayout returns parent-relative coordinates. In pageSheet modals,
the parent's y=0 doesn't correspond to screen y=0, causing the
keyboard avoidance calculation to use incorrect absolute positions.
This commit fixes two issues:
1. Use measureInWindow instead of onLayout to get absolute screen
coordinates. This ensures frame.y reflects the actual screen
position, not the parent-relative position.
2. Compensate for the gap below pageSheet modals. In pageSheet
presentation, the modal doesn't extend to the screen bottom,
but the keyboard covers this gap. The overlap calculation now
treats the view as extending to the screen bottom when it
detects a modal-like configuration (gap > 0, gap < keyboard
height, view > 50% of screen).
A combinedRef is used to maintain both the internal ref (needed
for measureInWindow) and the forwarded ref from the consumer.
Fixes #867
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent d4f1a4c commit 5efd60f
1 file changed
Lines changed: 45 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
107 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
| |||
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
135 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
136 | 166 | | |
137 | 167 | | |
138 | 168 | | |
| |||
177 | 207 | | |
178 | 208 | | |
179 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
180 | 220 | | |
181 | 221 | | |
182 | 222 | | |
| |||
186 | 226 | | |
187 | 227 | | |
188 | 228 | | |
189 | | - | |
| 229 | + | |
190 | 230 | | |
191 | 231 | | |
192 | 232 | | |
193 | 233 | | |
194 | 234 | | |
195 | 235 | | |
196 | 236 | | |
197 | | - | |
| 237 | + | |
198 | 238 | | |
199 | 239 | | |
200 | 240 | | |
| |||
0 commit comments