Skip to content
Snippets Groups Projects
Unverified Commit 506fa7ca authored by gabriellsh's avatar gabriellsh Committed by GitHub
Browse files

fix: Layout shift on room body when loading uikit messages (#31894)

parent 0570f674
No related branches found
No related tags found
No related merge requests found
---
"@rocket.chat/meteor": patch
---
fixed a small issue that was causing the room layout to shift when loading apps messages
import type { IMessage, IRoom } from '@rocket.chat/core-typings'; import type { IMessage, IRoom } from '@rocket.chat/core-typings';
import { MessageBlock, Skeleton } from '@rocket.chat/fuselage'; import { MessageBlock } from '@rocket.chat/fuselage';
import { UiKitComponent, UiKitMessage as UiKitMessageSurfaceRender, UiKitContext } from '@rocket.chat/fuselage-ui-kit'; import { UiKitComponent, UiKitMessage as UiKitMessageSurfaceRender, UiKitContext } from '@rocket.chat/fuselage-ui-kit';
import type { MessageSurfaceLayout } from '@rocket.chat/ui-kit'; import type { MessageSurfaceLayout } from '@rocket.chat/ui-kit';
import React, { Suspense } from 'react'; import React from 'react';
import { useMessageBlockContextValue } from '../../../uikit/hooks/useMessageBlockContextValue'; import { useMessageBlockContextValue } from '../../../uikit/hooks/useMessageBlockContextValue';
import GazzodownText from '../../GazzodownText'; import GazzodownText from '../../GazzodownText';
...@@ -20,9 +20,7 @@ const UiKitMessageBlock = ({ rid, mid, blocks }: UiKitMessageBlockProps) => { ...@@ -20,9 +20,7 @@ const UiKitMessageBlock = ({ rid, mid, blocks }: UiKitMessageBlockProps) => {
<MessageBlock fixedWidth> <MessageBlock fixedWidth>
<UiKitContext.Provider value={contextValue}> <UiKitContext.Provider value={contextValue}>
<GazzodownText> <GazzodownText>
<Suspense fallback={<Skeleton />}> <UiKitComponent render={UiKitMessageSurfaceRender} blocks={blocks} />
<UiKitComponent render={UiKitMessageSurfaceRender} blocks={blocks} />
</Suspense>
</GazzodownText> </GazzodownText>
</UiKitContext.Provider> </UiKitContext.Provider>
</MessageBlock> </MessageBlock>
......
import { Skeleton } from '@rocket.chat/fuselage';
import { Markup } from '@rocket.chat/gazzodown'; import { Markup } from '@rocket.chat/gazzodown';
import { parse } from '@rocket.chat/message-parser'; import { parse } from '@rocket.chat/message-parser';
import type { TextObject } from '@rocket.chat/ui-kit'; import type { TextObject } from '@rocket.chat/ui-kit';
import { Suspense } from 'react';
import { useAppTranslation } from '../hooks/useAppTranslation'; import { useAppTranslation } from '../hooks/useAppTranslation';
...@@ -15,7 +17,11 @@ const MarkdownTextElement = ({ textObject }: { textObject: TextObject }) => { ...@@ -15,7 +17,11 @@ const MarkdownTextElement = ({ textObject }: { textObject: TextObject }) => {
return null; return null;
} }
return <Markup tokens={parse(text, { emoticons: false })} />; return (
<Suspense fallback={<Skeleton />}>
<Markup tokens={parse(text, { emoticons: false })} />;
</Suspense>
);
}; };
export default MarkdownTextElement; export default MarkdownTextElement;
import type * as MessageParser from '@rocket.chat/message-parser'; import type * as MessageParser from '@rocket.chat/message-parser';
import type { ReactElement } from 'react'; import type { ReactElement } from 'react';
import { lazy } from 'react';
import CodeElement from '../code/CodeElement';
import EmojiElement from '../emoji/EmojiElement'; import EmojiElement from '../emoji/EmojiElement';
import ChannelMentionElement from '../mentions/ChannelMentionElement'; import ChannelMentionElement from '../mentions/ChannelMentionElement';
import UserMentionElement from '../mentions/UserMentionElement'; import UserMentionElement from '../mentions/UserMentionElement';
...@@ -10,8 +10,6 @@ import LinkSpan from './LinkSpan'; ...@@ -10,8 +10,6 @@ import LinkSpan from './LinkSpan';
import PlainSpan from './PlainSpan'; import PlainSpan from './PlainSpan';
import StrikeSpan from './StrikeSpan'; import StrikeSpan from './StrikeSpan';
const CodeElement = lazy(() => import('../code/CodeElement'));
type MessageBlock = type MessageBlock =
| MessageParser.Emoji | MessageParser.Emoji
| MessageParser.ChannelMention | MessageParser.ChannelMention
......
import type * as MessageParser from '@rocket.chat/message-parser'; import type * as MessageParser from '@rocket.chat/message-parser';
import { lazy, ReactElement } from 'react'; import { lazy, ReactElement } from 'react';
import CodeElement from '../code/CodeElement';
import ColorElement from '../colors/ColorElement'; import ColorElement from '../colors/ColorElement';
import EmojiElement from '../emoji/EmojiElement'; import EmojiElement from '../emoji/EmojiElement';
import KatexErrorBoundary from '../katex/KatexErrorBoundary'; import KatexErrorBoundary from '../katex/KatexErrorBoundary';
...@@ -14,7 +15,6 @@ import PlainSpan from './PlainSpan'; ...@@ -14,7 +15,6 @@ import PlainSpan from './PlainSpan';
import StrikeSpan from './StrikeSpan'; import StrikeSpan from './StrikeSpan';
import Timestamp from './Timestamp'; import Timestamp from './Timestamp';
const CodeElement = lazy(() => import('../code/CodeElement'));
const KatexElement = lazy(() => import('../katex/KatexElement')); const KatexElement = lazy(() => import('../katex/KatexElement'));
type InlineElementsProps = { type InlineElementsProps = {
......
import type * as MessageParser from '@rocket.chat/message-parser'; import type * as MessageParser from '@rocket.chat/message-parser';
import type { ReactElement } from 'react'; import type { ReactElement } from 'react';
import { lazy } from 'react';
import CodeElement from '../code/CodeElement';
import EmojiElement from '../emoji/EmojiElement'; import EmojiElement from '../emoji/EmojiElement';
import ChannelMentionElement from '../mentions/ChannelMentionElement'; import ChannelMentionElement from '../mentions/ChannelMentionElement';
import UserMentionElement from '../mentions/UserMentionElement'; import UserMentionElement from '../mentions/UserMentionElement';
...@@ -10,8 +10,6 @@ import LinkSpan from './LinkSpan'; ...@@ -10,8 +10,6 @@ import LinkSpan from './LinkSpan';
import PlainSpan from './PlainSpan'; import PlainSpan from './PlainSpan';
import StrikeSpan from './StrikeSpan'; import StrikeSpan from './StrikeSpan';
const CodeElement = lazy(() => import('../code/CodeElement'));
type MessageBlock = type MessageBlock =
| MessageParser.Emoji | MessageParser.Emoji
| MessageParser.ChannelMention | MessageParser.ChannelMention
......
import type * as MessageParser from '@rocket.chat/message-parser'; import type * as MessageParser from '@rocket.chat/message-parser';
import type { ReactElement } from 'react'; import type { ReactElement } from 'react';
import { lazy } from 'react';
import CodeElement from '../code/CodeElement';
import EmojiElement from '../emoji/EmojiElement'; import EmojiElement from '../emoji/EmojiElement';
import ChannelMentionElement from '../mentions/ChannelMentionElement'; import ChannelMentionElement from '../mentions/ChannelMentionElement';
import UserMentionElement from '../mentions/UserMentionElement'; import UserMentionElement from '../mentions/UserMentionElement';
...@@ -10,8 +10,6 @@ import ItalicSpan from './ItalicSpan'; ...@@ -10,8 +10,6 @@ import ItalicSpan from './ItalicSpan';
import LinkSpan from './LinkSpan'; import LinkSpan from './LinkSpan';
import PlainSpan from './PlainSpan'; import PlainSpan from './PlainSpan';
const CodeElement = lazy(() => import('../code/CodeElement'));
type MessageBlock = type MessageBlock =
| MessageParser.Timestamp | MessageParser.Timestamp
| MessageParser.Emoji | MessageParser.Emoji
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment