Support for creating New Groups
This commit is contained in:
parent
1934120e46
commit
5de4babc0d
56 changed files with 6222 additions and 526 deletions
38
ts/components/ContactPills.tsx
Normal file
38
ts/components/ContactPills.tsx
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React, {
|
||||
useRef,
|
||||
useEffect,
|
||||
Children,
|
||||
FunctionComponent,
|
||||
ReactNode,
|
||||
} from 'react';
|
||||
|
||||
type PropsType = {
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export const ContactPills: FunctionComponent<PropsType> = ({ children }) => {
|
||||
const elRef = useRef<null | HTMLDivElement>(null);
|
||||
|
||||
const childCount = Children.count(children);
|
||||
const previousChildCountRef = useRef<number>(childCount);
|
||||
const previousChildCount = previousChildCountRef.current;
|
||||
previousChildCountRef.current = childCount;
|
||||
|
||||
useEffect(() => {
|
||||
const hasAddedNewChild = childCount > previousChildCount;
|
||||
const el = elRef.current;
|
||||
if (!hasAddedNewChild || !el) {
|
||||
return;
|
||||
}
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}, [childCount, previousChildCount]);
|
||||
|
||||
return (
|
||||
<div className="module-ContactPills" ref={elRef}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue