Skip to content

feat: expose isAtEnd shared value from KeyboardChatScrollView#1431

Open
jkinggg wants to merge 1 commit intokirillzyusko:mainfrom
jkinggg:feat/expose-is-at-end
Open

feat: expose isAtEnd shared value from KeyboardChatScrollView#1431
jkinggg wants to merge 1 commit intokirillzyusko:mainfrom
jkinggg:feat/expose-is-at-end

Conversation

@jkinggg
Copy link
Copy Markdown

@jkinggg jkinggg commented Apr 10, 2026

📜 Description

This PR adds an optional isAtEnd?: SharedValue<boolean> prop to KeyboardChatScrollView.

When provided, the component updates that shared value on the UI thread using the same internal scroll metrics and isScrollAtEnd(...) logic already used by keyboardLiftBehavior="whenAtEnd".

The goal is to let chat-style apps build jump-to-latest / scroll-to-bottom affordances without reimplementing the component's internal "at end" logic in app code.

💡 Motivation and Context

This change is intended to solve a common gap in chat UIs:

  • the component already knows whether the user is effectively at the end
  • apps often need that same signal for follow-mode and jump-to-latest UI
  • today, consumers must guess based on external scroll heuristics

That duplication is brittle because app-side heuristics can diverge from the component's own keyboard-aware behavior.

This PR keeps the API small by exposing the semantic state (isAtEnd) instead of lower-level raw scroll metrics.

Related issue: #1430

📢 Changelog

JS

  • add optional isAtEnd?: SharedValue<boolean> prop to KeyboardChatScrollView
  • update isAtEnd on the UI thread using existing isScrollAtEnd(...) logic
  • add TypeScript declarations for the new prop

iOS

  • no native changes

Android

  • no native changes

🤔 How Has This Been Tested?

Validated in the fork clone with:

  • yarn typescript
  • yarn lint src/components/KeyboardChatScrollView/index.tsx src/components/KeyboardChatScrollView/types.ts

Not yet completed before opening this draft PR:

  • yarn test
  • manual verification in the example app on iOS
  • manual verification in the example app on Android

📸 Screenshots (if appropriate):

No screenshots yet. This draft PR is mainly to support API discussion from #1430.

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Apr 14, 2026
@kirillzyusko kirillzyusko self-requested a review April 14, 2026 11:45
@kirillzyusko kirillzyusko added enhancement New feature or request KeyboardChatScrollView 💬 Anything about chat functionality labels Apr 14, 2026
@kirillzyusko
Copy link
Copy Markdown
Owner

Hey @jkinggg

Is it final PR? Can we move it to "ready for review" stage?

Copy link
Copy Markdown
Author

@jkinggg jkinggg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kirillzyusko this is ready

@kirillzyusko kirillzyusko marked this pull request as ready for review April 17, 2026 08:22
@github-actions
Copy link
Copy Markdown
Contributor

📊 Package size report

Current size Target Size Difference
313911 bytes 312781 bytes 1130 bytes 📈

@kirillzyusko
Copy link
Copy Markdown
Owner

kirillzyusko commented Apr 27, 2026

Hey @jkinggg

Thank you for PR! (And sorry for a long review, last week I was busy with other problems and couldn't allocate a time for supporting/developing this library).

Overall I'm not agains of having these changes in the lib. However one thing that concerns me is that we violate React rules by passing a mutable property... I think it's not really react style? Do you think we can pass custom callback, like onAtEnd (or any other name, I don't want to use onEndReached because this prop already exist in FlatList) and run this callback in reaction effect?

In this case it will be more customizable behavior, because developer may want to write custom functionality when end is reached (not only changing shared variable)?

What do you think about callback approach? 👀

* When provided, `KeyboardChatScrollView` updates it on the UI thread using the same
* scroll metrics that drive `keyboardLiftBehavior="whenAtEnd"`.
*/
isAtEnd?: SharedValue<boolean>;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also will need to update documentation (next version and current 1.21), but I can do it for you if you prefer 😊

@kirillzyusko
Copy link
Copy Markdown
Owner

Hey @jkinggg

So what do you think about the callback approach? 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request KeyboardChatScrollView 💬 Anything about chat functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants