Skip to content

Commit

Permalink
🐛 fix: 清空对话后,【返回底部】按钮未隐藏 #183 (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
mannix-lei authored Aug 2, 2024
1 parent 2e8f295 commit 9843405
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ProChat/container/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { useOverrideStyles } from './OverrideStyle';
import { ProChatChatReference } from './StoreUpdater';
import { ProChatProps } from './index';

import { useStore } from '@/ProChat/store';
import { chatSelectors } from '@/ProChat/store/selectors';

const useStyles = createStyles(
({ css, responsive, stylish }) => css`
overflow: hidden scroll;
Expand Down Expand Up @@ -103,6 +106,8 @@ const App = memo<ConversationProps>(
const [height, setHeight] = useState('100%' as string | number);
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const { localeObject } = useProChatLocale();
const messages = useStore(chatSelectors.currentChats);
const [backBottomVisiable, setBackBottomVisiable] = useState<boolean>(messages?.length > 0);

useEffect(() => {
// 保证 ref 永远存在
Expand All @@ -118,6 +123,10 @@ const App = memo<ConversationProps>(
}
}, []);

useEffect(() => {
setBackBottomVisiable(messages?.length > 0);
}, [messages]);

const prefixClass = getPrefixCls('pro-chat');
return (
<RcResizeObserver
Expand Down Expand Up @@ -157,7 +166,7 @@ const App = memo<ConversationProps>(
/>
{ref?.current && <ChatScrollAnchor target={ref} />}
</div>
{isRender && ref?.current ? (
{isRender && backBottomVisiable && ref?.current ? (
<BackBottom
style={{
bottom: 138,
Expand Down

0 comments on commit 9843405

Please sign in to comment.