Skip to content

Commit 4235cd9

Browse files
authored
fix(ui): Expanded thread view overlapping NavBar (#39892)
1 parent fec3c9f commit 4235cd9

File tree

2 files changed

+82
-55
lines changed

2 files changed

+82
-55
lines changed

.changeset/stale-drinks-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/meteor': patch
3+
---
4+
5+
Fixes an issue where the expanded thread view was overlapping the navbar

apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx

Lines changed: 77 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
useUserId,
2020
useRoomToolbox,
2121
} from '@rocket.chat/ui-contexts';
22+
import { createPortal } from 'react-dom';
2223

2324
import ThreadChat from './components/ThreadChat';
2425
import ThreadSkeleton from './components/ThreadSkeleton';
@@ -82,64 +83,85 @@ const Thread = ({ tmid }: ThreadProps) => {
8283
closeTab();
8384
};
8485

86+
const isExpanded = canExpand && expanded;
87+
const portalTarget = isExpanded ? document.getElementById('main-content') : null;
88+
89+
const threadContent = (
90+
<Contextualbar
91+
rcx-thread-view
92+
className={
93+
isExpanded
94+
? css`
95+
max-width: 855px !important;
96+
@media (min-width: 780px) and (max-width: 1135px) {
97+
max-width: calc(100% - var(--sidebar-width)) !important;
98+
}
99+
`
100+
: undefined
101+
}
102+
position='absolute'
103+
display='flex'
104+
flexDirection='column'
105+
width='full'
106+
overflow='hidden'
107+
zIndex={100}
108+
insetBlock={0}
109+
border='none'
110+
>
111+
<ContextualbarHeader>
112+
<ContextualbarBack onClick={handleGoBack} />
113+
{(mainMessageQueryResult.isLoading && <Skeleton width='100%' />) ||
114+
(mainMessageQueryResult.isSuccess && <ThreadTitle mainMessage={mainMessageQueryResult.data} />) ||
115+
null}
116+
<ContextualbarActions>
117+
{canExpand && (
118+
<ContextualbarAction
119+
name={expanded ? 'arrow-collapse' : 'arrow-expand'}
120+
title={expanded ? t('Collapse') : t('Expand')}
121+
onClick={handleToggleExpand}
122+
/>
123+
)}
124+
<ContextualbarAction
125+
name={following ? 'bell' : 'bell-off'}
126+
title={following ? t('Following') : t('Not_Following')}
127+
disabled={!mainMessageQueryResult.isSuccess || toggleFollowingMutation.isPending}
128+
onClick={handleToggleFollowing}
129+
/>
130+
<ContextualbarClose onClick={handleClose} />
131+
</ContextualbarActions>
132+
</ContextualbarHeader>
133+
134+
{(mainMessageQueryResult.isLoading && <ThreadSkeleton />) ||
135+
(mainMessageQueryResult.isSuccess && (
136+
<ChatProvider tmid={tmid}>
137+
<ThreadChat mainMessage={mainMessageQueryResult.data} />
138+
</ChatProvider>
139+
)) ||
140+
null}
141+
</Contextualbar>
142+
);
143+
85144
return (
86145
<ContextualbarDialog>
87146
<ContextualbarInnerContent>
88-
{canExpand && expanded && <ModalBackdrop onClick={handleBackdropClick} />}
89-
<Box flexGrow={1} position={expanded ? 'static' : 'relative'}>
90-
<Contextualbar
91-
rcx-thread-view
92-
className={
93-
canExpand && expanded
94-
? css`
95-
max-width: 855px !important;
96-
@media (min-width: 780px) and (max-width: 1135px) {
97-
max-width: calc(100% - var(--sidebar-width)) !important;
98-
}
99-
`
100-
: undefined
101-
}
102-
position={expanded ? 'fixed' : 'absolute'}
103-
display='flex'
104-
flexDirection='column'
105-
width='full'
106-
overflow='hidden'
107-
zIndex={100}
108-
insetBlock={0}
109-
border='none'
110-
>
111-
<ContextualbarHeader>
112-
<ContextualbarBack onClick={handleGoBack} />
113-
{(mainMessageQueryResult.isLoading && <Skeleton width='100%' />) ||
114-
(mainMessageQueryResult.isSuccess && <ThreadTitle mainMessage={mainMessageQueryResult.data} />) ||
115-
null}
116-
<ContextualbarActions>
117-
{canExpand && (
118-
<ContextualbarAction
119-
name={expanded ? 'arrow-collapse' : 'arrow-expand'}
120-
title={expanded ? t('Collapse') : t('Expand')}
121-
onClick={handleToggleExpand}
122-
/>
123-
)}
124-
<ContextualbarAction
125-
name={following ? 'bell' : 'bell-off'}
126-
title={following ? t('Following') : t('Not_Following')}
127-
disabled={!mainMessageQueryResult.isSuccess || toggleFollowingMutation.isPending}
128-
onClick={handleToggleFollowing}
129-
/>
130-
<ContextualbarClose onClick={handleClose} />
131-
</ContextualbarActions>
132-
</ContextualbarHeader>
133-
134-
{(mainMessageQueryResult.isLoading && <ThreadSkeleton />) ||
135-
(mainMessageQueryResult.isSuccess && (
136-
<ChatProvider tmid={tmid}>
137-
<ThreadChat mainMessage={mainMessageQueryResult.data} />
138-
</ChatProvider>
139-
)) ||
140-
null}
141-
</Contextualbar>
142-
</Box>
147+
{portalTarget ? (
148+
createPortal(
149+
<>
150+
<ModalBackdrop
151+
className={css`
152+
position: absolute !important;
153+
`}
154+
onClick={handleBackdropClick}
155+
/>
156+
{threadContent}
157+
</>,
158+
portalTarget,
159+
)
160+
) : (
161+
<Box flexGrow={1} position='relative'>
162+
{threadContent}
163+
</Box>
164+
)}
143165
</ContextualbarInnerContent>
144166
</ContextualbarDialog>
145167
);

0 commit comments

Comments
 (0)