Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: merge additionalVirtuosoProps "components" property with VirtualizedMessageList's "virtuosoComponents" #2136

Closed
1 task
trophied opened this issue Oct 18, 2023 · 1 comment
Assignees
Labels
feature New capability status:confirmed Described issue has been reproduced by the repo maintainer

Comments

@trophied
Copy link

trophied commented Oct 18, 2023

Motivation

In cases where a consumer of VirtualizedMessageList might want to override the components that react-virtuoso allows them to using the components prop, the existing wrapper does allow you to pass in overrides, but, if you pass in any overrides, you end up opting out of the overrides provided by VirtualizedMessageList out of the box like Header, Footer, EmptyPlaceholder, and Item.

Proposed solution

It would be nice if the final value of components that is provided to react-virtuoso would was a combination of additionalVirtuosoProps.components and virtuosoProps (see here).

Something like the example below, though to preserve the memo it might require breaking out the components themselves as individual dependencies.

// VirtualizedMessageList.tsx

const { components, ...virtuosoProps } = additionalVirtuosoProps;

const virtuosoComponents: Partial<Components> = useMemo(() => {
  const EmptyPlaceholder: Components['EmptyPlaceholder'] = () => (
    <>
      {EmptyStateIndicator && (
        <EmptyStateIndicator listType={threadList ? 'thread' : 'message'} />
      )}
    </>
  );

  const Header: Components['Header'] = () =>
    loadingMore ? (
      <div className='str-chat__virtual-list__loading'>
        <LoadingIndicator size={20} />
      </div>
    ) : (
      head || null
    );

  const Footer: Components['Footer'] = () =>
    TypingIndicator ? <TypingIndicator avatarSize={24} /> : <></>;

  const streamChatVirtuosoComponents = {
    EmptyPlaceholder,
    Footer,
    Header,
    Item,
  }

  return components
    ? { ...streamChatVirtuosoComponents, ...components }
    : streamChatVirtuosoComponents
}, [components, loadingMore, head, Item]);

// ...

return (
  // ...
  <Virtuoso
    // ....
    components={virtuosoComponents}
    {...virtuosoProps}
    // ...
  />
  // ...
)

Acceptance Criteria

  • Ability to set virtuoso components like Scroller through additionalVirtuosoProps without losing Header, Footer, EmptyPlaceholder, and Item components provided by VirtualizedMessageList in the process.
@trophied trophied added the feature New capability label Oct 18, 2023
@arnautov-anton arnautov-anton added the status:confirmed Described issue has been reproduced by the repo maintainer label Oct 18, 2023
@MartinCupela
Copy link
Contributor

fixed by #2140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New capability status:confirmed Described issue has been reproduced by the repo maintainer
Projects
None yet
Development

No branches or pull requests

3 participants