feat: expose isAtEnd shared value from KeyboardChatScrollView#1431
feat: expose isAtEnd shared value from KeyboardChatScrollView#1431jkinggg wants to merge 1 commit intokirillzyusko:mainfrom
isAtEnd shared value from KeyboardChatScrollView#1431Conversation
|
Hey @jkinggg Is it final PR? Can we move it to "ready for review" stage? |
jkinggg
left a comment
There was a problem hiding this comment.
Hey @kirillzyusko this is ready
📊 Package size report
|
|
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 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>; |
There was a problem hiding this comment.
We also will need to update documentation (next version and current 1.21), but I can do it for you if you prefer 😊
|
Hey @jkinggg So what do you think about the |
📜 Description
This PR adds an optional
isAtEnd?: SharedValue<boolean>prop toKeyboardChatScrollView.When provided, the component updates that shared value on the UI thread using the same internal scroll metrics and
isScrollAtEnd(...)logic already used bykeyboardLiftBehavior="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:
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
isAtEnd?: SharedValue<boolean>prop toKeyboardChatScrollViewisAtEndon the UI thread using existingisScrollAtEnd(...)logiciOS
Android
🤔 How Has This Been Tested?
Validated in the fork clone with:
yarn typescriptyarn lint src/components/KeyboardChatScrollView/index.tsx src/components/KeyboardChatScrollView/types.tsNot yet completed before opening this draft PR:
yarn test📸 Screenshots (if appropriate):
No screenshots yet. This draft PR is mainly to support API discussion from #1430.
📝 Checklist