stream-chat-react icon indicating copy to clipboard operation
stream-chat-react copied to clipboard

fix: rely on MessageList scroll management in Thread component

Open MartinCupela opened this issue 2 years ago • 2 comments

🎯 Goal

  1. When thread is open no additional pagination requests are executed for the query message list
  2. When thread is open Thread's message list is scrolled to the bottom

Depends on https://github.com/GetStream/stream-chat-css/pull/123

Acceptance criteria

User scenarios

Prerequisite: the message list scroll height inside the thread has to be greater than the height of its parent forcing the scrolling behavior

  • [X] User does not scroll and opens a thread
  • [X] User scrolls up to a message that has to be additionally loaded by pagination -> opens its thread

Out of scope (target of #1631):

  • User click quoted message that does not have to be loaded by additional HTTP request -> opens its thread
  • User click quoted message that has to be loaded by additional HTTP request -> opens its thread
Expected behavior:
  1. The thread is scrolled to the bottom on open
  2. The pagination requests do not take place
Tests
E2E tests:

All the above scenarios have to be covered

  • [X] non-virtualized message list
Unit tests
  • [X] All the have to be adjusted to the refactor + added new where needed
Documentation
  • [X] Document the possibility to pass custom MessageListHead component to context
  • [X] Document the component API changes

🛠 Implementation details

New component MessageListHead head was introduced. It contains the Message component rendering the parent message and ThreadStart component. These were originally excluded from the message list what broke the scroll logic. This PR changes this and includes the parent message with start thread indicator within the list of message elements generated by useMessageListElements.

MartinCupela avatar Jun 08 '22 20:06 MartinCupela

Codecov Report

Merging #1618 (4d820a9) into theming-v2 (14c1f6f) will increase coverage by 0.11%. The diff coverage is 88.88%.

@@              Coverage Diff               @@
##           theming-v2    GetStream/stream-chat-react#1618      +/-   ##
==============================================
+ Coverage       79.34%   79.46%   +0.11%     
==============================================
  Files             229      232       +3     
  Lines            5800     5819      +19     
  Branches         1708     1709       +1     
==============================================
+ Hits             4602     4624      +22     
+ Misses           1051     1049       -2     
+ Partials          147      146       -1     
Impacted Files Coverage Δ
src/components/Channel/channelState.ts 63.41% <ø> (ø)
...nents/MessageList/hooks/useScrollLocationLogic.tsx 65.00% <ø> (ø)
src/context/ChannelStateContext.tsx 57.89% <ø> (ø)
src/context/ChatContext.tsx 63.15% <ø> (ø)
src/context/ComponentContext.tsx 57.89% <ø> (ø)
src/components/MessageList/MessageList.tsx 85.71% <50.00%> (-1.30%) :arrow_down:
...nents/MessageList/hooks/useMessageListElements.tsx 88.88% <81.25%> (+0.65%) :arrow_up:
src/components/Channel/Channel.tsx 80.95% <88.88%> (+0.06%) :arrow_up:
src/components/Thread/Thread.tsx 98.33% <91.66%> (+7.42%) :arrow_up:
...ponents/InfiniteScrollPaginator/InfiniteScroll.tsx 70.00% <100.00%> (+1.25%) :arrow_up:
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 14c1f6f...4d820a9. Read the comment docs.

codecov[bot] avatar Jun 15 '22 21:06 codecov[bot]

Changing the target branch to theming-v2 as the breaking change in markup in thread message list (removal of div container around it is removed).

MartinCupela avatar Jun 19 '22 05:06 MartinCupela