Skip to content

Commit 7286b9d

Browse files
thomasvoclaude
andcommitted
chore: improve else-branch comment for zero-context readability
Rewrite the automaticOffset else-branch comment to explain the full chain: why the if-branch skips updates, why automaticOffset needs the correction, and why height is preserved. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 311bfae commit 7286b9d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/components/KeyboardAvoidingView/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,14 @@ const KeyboardAvoidingView = forwardRef<
140140
// eslint-disable-next-line react-compiler/react-compiler
141141
initialFrame.value = layout;
142142
} else if (automaticOffset) {
143-
// Only automaticOffset needs this: measureInWindow can return stale
144-
// y=0 during modal animation, and since isClosed is already false
145-
// here, the corrected y from the next onLayout would be dropped.
146-
// Preserve original height to avoid feedback loop.
143+
// The if-branch above skips layout updates in height mode while
144+
// the keyboard is open to prevent a feedback loop (shrunk height
145+
// stored → animatedStyle recalculates → view resizes → repeat).
146+
// But automaticOffset uses measureInWindow which can return stale
147+
// y=0 during modal animation — the corrected y arrives on the
148+
// next onLayout (when the view resizes for the keyboard) and
149+
// would be dropped without this branch. So accept position
150+
// updates but keep the original height.
147151
// eslint-disable-next-line react-compiler/react-compiler
148152
initialFrame.value = {
149153
x: layout.x,

0 commit comments

Comments
 (0)