Inline Bot Tooltip: Fix closing animation on sending (#2031)

This commit is contained in:
Alexander Zinchuk 2022-09-13 10:22:46 +02:00
parent 45dee440a7
commit b7bf020eb4

View File

@ -14,6 +14,7 @@ import useShowTransition from '../../../hooks/useShowTransition';
import { throttle } from '../../../util/schedulers';
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
import usePrevious from '../../../hooks/usePrevious';
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
import MediaResult from './inlineResults/MediaResult';
@ -65,6 +66,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
const renderedIsGallery = useCurrentOrPrev(isGallery, shouldRender);
const {
observe: observeIntersection,
} = useIntersectionObserver({
@ -81,8 +83,8 @@ const InlineBotTooltip: FC<OwnProps> = ({
const selectedIndex = useKeyboardNavigation({
isActive: isOpen,
shouldRemoveSelectionOnReset: isGallery,
noArrowNavigation: isGallery,
shouldRemoveSelectionOnReset: renderedIsGallery,
noArrowNavigation: renderedIsGallery,
items: inlineBotResults,
onSelect: onSelectResult,
onClose,
@ -103,9 +105,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
: undefined,
shouldRender,
);
const renderedInlineBotResults = inlineBotResults && !inlineBotResults.length
? prevInlineBotResults
: inlineBotResults;
const renderedInlineBotResults = inlineBotResults?.length ? inlineBotResults : prevInlineBotResults;
if (!shouldRender || !(renderedInlineBotResults?.length || switchPm)) {
return undefined;
@ -114,7 +114,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
const className = buildClassName(
'InlineBotTooltip composer-tooltip',
IS_TOUCH_ENV ? 'no-scrollbar' : 'custom-scroll',
isGallery && 'gallery',
renderedIsGallery && 'gallery',
transitionClassNames,
);
@ -145,7 +145,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
return (
<MediaResult
key={inlineBotResult.id}
isForGallery={isGallery}
isForGallery={renderedIsGallery}
inlineResult={inlineBotResult}
onClick={onSelectResult}
/>