Skip to content

Commit 76f941a

Browse files
nicodhWofWca
andauthored
Avoid line breaks in webxdc-info (#5264)
* Avoid line breaks in webxdc-info * Fix height for message bubble --------- Co-authored-by: WofWca <wofwca@protonmail.com>
1 parent 7ac8e85 commit 76f941a

File tree

4 files changed

+61
-9
lines changed

4 files changed

+61
-9
lines changed

packages/frontend/scss/message/_message.scss

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
@use '../mixins';
22
@use '../variables';
33

4+
// limit for text width, needed to trigger ellipsis
5+
$info-text-max-width: 400px;
6+
47
.message-wrapper {
58
--shortcut-menu-visibility: hidden;
69
--shortcut-menu-multiplier: 0;
@@ -121,9 +124,59 @@
121124
// firefox does not support this, but chromium and webkit do https://caniuse.com/?search=user-drag
122125
-webkit-user-drag: none;
123126
}
124-
div.name {
127+
// nowrap and min-height address the problem that
128+
// the height of a message bubble should not change
129+
// after it's first load, even if the content changes
130+
// after loading webxdcInfo async
131+
// see https://github.com/deltachat/deltachat-desktop/issues/3753
132+
div.info-text {
133+
display: flex;
134+
flex-direction: row;
135+
max-width: $info-text-max-width;
136+
min-width: 0;
137+
white-space: nowrap;
125138
font-size: medium;
126139
font-weight: 300;
140+
gap: 3px;
141+
}
142+
div.name {
143+
min-width: 0;
144+
overflow: hidden;
145+
text-overflow: ellipsis;
146+
white-space: nowrap;
147+
}
148+
div.document {
149+
flex-shrink: 999999999999999;
150+
min-width: 0;
151+
overflow: hidden;
152+
text-overflow: ellipsis;
153+
white-space: nowrap;
154+
&:not(:empty)::after {
155+
content: '';
156+
margin-left: 3px;
157+
}
158+
&:empty {
159+
display: none;
160+
}
161+
}
162+
div.summary {
163+
white-space: nowrap;
164+
overflow: hidden;
165+
text-overflow: ellipsis;
166+
max-width: $info-text-max-width;
167+
168+
$font-size: 0.875rem;
169+
$line-height: 1.15;
170+
font-size: $font-size;
171+
line-height: $line-height;
172+
// Ensure that even if the element is empty
173+
// (e.g. while we're loading `webxdcInfo`),
174+
// it still takes height, so that when the info finally loads
175+
// and `summary` is present, the message bubble doesn't get taller,
176+
// which would result in the message list getting scrolled.
177+
// See
178+
// https://github.com/deltachat/deltachat-desktop/pull/5227#discussion_r2173774006.
179+
min-height: calc($font-size * $line-height);
127180
}
128181
div.experimental {
129182
color: var(--colorDanger);

packages/frontend/src/components/attachment/messageAttachment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export function DraftAttachment({
236236
attachment: MessageTypeAttachmentSubset
237237
}) {
238238
const [webxdcInfo, setWebxdcInfo] = useState<T.WebxdcMessageInfo | null>(null)
239-
const [isLoadingWebxdcInfo, setIsLoadingWebxdcInfo] = useState(false)
239+
const [isLoadingWebxdcInfo, setIsLoadingWebxdcInfo] = useState(true)
240240
const accountId = selectedAccountId()
241241

242242
const lastFileNameRef = useRef<string | null>(null)

packages/frontend/src/components/message/Message.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { isGenericAttachment, isImage } from '../attachment/Attachment'
3131
import { runtime } from '@deltachat-desktop/runtime-interface'
3232
import { AvatarFromContact } from '../Avatar'
3333
import { ConversationType } from './MessageList'
34-
import { truncateText } from '@deltachat-desktop/shared/util'
3534
import { getDirection } from '../../utils/getDirection'
3635
import { mapCoreMsgStatus2String } from '../helpers/MapMsgStatus'
3736
import { ContextMenuItem } from '../ContextMenu'
@@ -1118,7 +1117,7 @@ function WebxdcMessageContent({
11181117
}) {
11191118
const tx = useTranslationFunction()
11201119
const [webxdcInfo, setWebxdcInfo] = useState<T.WebxdcMessageInfo | null>(null)
1121-
const [isLoadingWebxdcInfo, setIsLoadingWebxdcInfo] = useState(false)
1120+
const [isLoadingWebxdcInfo, setIsLoadingWebxdcInfo] = useState(true)
11221121
const accountId = selectedAccountId()
11231122

11241123
const fetchWebxdcInfo = useCallback(async () => {
@@ -1191,13 +1190,13 @@ function WebxdcMessageContent({
11911190
// because there is a button below that does the same
11921191
/>
11931192
<div
1194-
className='name'
1193+
className='info-text'
11951194
title={`${info.document ? info.document + ' \n' : ''}${info.name}`}
11961195
>
1197-
{info.document && truncateText(info.document, 24) + ' - '}
1198-
{truncateText(info.name, 42)}
1196+
<div className='document'>{info.document}</div>
1197+
<div className='name'>{info.name}</div>
11991198
</div>
1200-
<div>{info.summary}</div>
1199+
<div className='summary'>{info.summary}</div>
12011200
<Button
12021201
className={styles.startWebxdcButton}
12031202
styling='primary'

packages/frontend/src/components/screens/MainScreen/MainScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ function ChatNavButtons({ chat }: { chat: T.FullChat }) {
448448

449449
function AppIcon({ accountId, app }: { accountId: number; app: T.Message }) {
450450
const [webxdcInfo, setWebxdcInfo] = useState<T.WebxdcMessageInfo | null>(null)
451-
const [isLoadingWebxdcInfo, setIsLoadingWebxdcInfo] = useState(false)
451+
const [isLoadingWebxdcInfo, setIsLoadingWebxdcInfo] = useState(true)
452452

453453
useEffect(() => {
454454
if (app.viewType === 'Webxdc') {

0 commit comments

Comments
 (0)