Mode-switching workaround for keyboard controller issue 1453#443
Mode-switching workaround for keyboard controller issue 1453#443trcoffman wants to merge 2 commits into
Conversation
wip: workaround wip: workaround
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5262e3619b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return; | ||
| } | ||
| return state.listen("totalSize", (totalSize) => { | ||
| if (totalSize > state.scrollLength + contentInsetEndAdjustment.value) { |
There was a problem hiding this comment.
Read the current scroll length before enabling anchored space
On Android/new-architecture mounts where the list ref is available before the final layout size is known, this captures the one-time getState() snapshot and keeps using its initial scrollLength for every later totalSize update. Since scrollLength is copied into the returned state object rather than kept live, the first content measurement can satisfy the check with a stale 0/old viewport and enable anchoredEndSpace while the content is still shorter than the actual viewport plus composer inset, reintroducing the KeyboardChatScrollView short-content path this guard is meant to avoid. Fetch the latest state inside the listener, or otherwise wait for the measured scroll length before flipping the flag.
Useful? React with 👍 / 👎.
On Android, only enable anchoredEndSpace and contentInsetEndAdjustment features once the content is long enough to not trigger issue 1453 in KeyboardChatScrollView.
kirillzyusko/react-native-keyboard-controller#1453
This also includes a commit to fix a bug in contentInsetEndAdjustment where changing it remounts the scrollview. This commit should be extracted to a separate PR and then this PR can get rebased.
This is a competing workaround with #442 and only one of them should be used.