Inline Bot Tooltip: Fix closing animation on sending (#2031)
This commit is contained in:
parent
45dee440a7
commit
b7bf020eb4
@ -14,6 +14,7 @@ import useShowTransition from '../../../hooks/useShowTransition';
|
|||||||
import { throttle } from '../../../util/schedulers';
|
import { throttle } from '../../../util/schedulers';
|
||||||
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePrevious from '../../../hooks/usePrevious';
|
||||||
|
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
||||||
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
||||||
|
|
||||||
import MediaResult from './inlineResults/MediaResult';
|
import MediaResult from './inlineResults/MediaResult';
|
||||||
@ -65,6 +66,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
||||||
|
const renderedIsGallery = useCurrentOrPrev(isGallery, shouldRender);
|
||||||
const {
|
const {
|
||||||
observe: observeIntersection,
|
observe: observeIntersection,
|
||||||
} = useIntersectionObserver({
|
} = useIntersectionObserver({
|
||||||
@ -81,8 +83,8 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const selectedIndex = useKeyboardNavigation({
|
const selectedIndex = useKeyboardNavigation({
|
||||||
isActive: isOpen,
|
isActive: isOpen,
|
||||||
shouldRemoveSelectionOnReset: isGallery,
|
shouldRemoveSelectionOnReset: renderedIsGallery,
|
||||||
noArrowNavigation: isGallery,
|
noArrowNavigation: renderedIsGallery,
|
||||||
items: inlineBotResults,
|
items: inlineBotResults,
|
||||||
onSelect: onSelectResult,
|
onSelect: onSelectResult,
|
||||||
onClose,
|
onClose,
|
||||||
@ -103,9 +105,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
: undefined,
|
: undefined,
|
||||||
shouldRender,
|
shouldRender,
|
||||||
);
|
);
|
||||||
const renderedInlineBotResults = inlineBotResults && !inlineBotResults.length
|
const renderedInlineBotResults = inlineBotResults?.length ? inlineBotResults : prevInlineBotResults;
|
||||||
? prevInlineBotResults
|
|
||||||
: inlineBotResults;
|
|
||||||
|
|
||||||
if (!shouldRender || !(renderedInlineBotResults?.length || switchPm)) {
|
if (!shouldRender || !(renderedInlineBotResults?.length || switchPm)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -114,7 +114,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
const className = buildClassName(
|
const className = buildClassName(
|
||||||
'InlineBotTooltip composer-tooltip',
|
'InlineBotTooltip composer-tooltip',
|
||||||
IS_TOUCH_ENV ? 'no-scrollbar' : 'custom-scroll',
|
IS_TOUCH_ENV ? 'no-scrollbar' : 'custom-scroll',
|
||||||
isGallery && 'gallery',
|
renderedIsGallery && 'gallery',
|
||||||
transitionClassNames,
|
transitionClassNames,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
return (
|
return (
|
||||||
<MediaResult
|
<MediaResult
|
||||||
key={inlineBotResult.id}
|
key={inlineBotResult.id}
|
||||||
isForGallery={isGallery}
|
isForGallery={renderedIsGallery}
|
||||||
inlineResult={inlineBotResult}
|
inlineResult={inlineBotResult}
|
||||||
onClick={onSelectResult}
|
onClick={onSelectResult}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user