Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-weird-empty-items-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

Fix lists with empty items looking wrong on FireFox
1 change: 1 addition & 0 deletions src/app/components/editor/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const getInlineElement = (node: ChildNode, processText: ProcessTextCallback): In
}

if (isTag(node)) {
if (node.name === 'p' && node?.children?.length === 0) return [{ text: '' }];
const markType = getInlineNodeMarkType(node);
if (markType) {
return getInlineMarkElement(markType, node, (child) => {
Expand Down
18 changes: 12 additions & 6 deletions src/app/components/message/MsgTypeRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,15 @@ export function MText({
const customBody =
typeof content.formatted_body === 'string' ? content.formatted_body : undefined;

const cleanedMessage = useMemo(
() => customBody?.replace(/<li>(<p><\/p>)?<\/li>/gi, '<li><br></li>'),
[customBody]
);

const trimmedBody = useMemo(() => trimReplyFromBody(body), [body]);
const unwrappedForwardedContent = useMemo(
() => unwrapForwardedContent(customBody ?? body),
[customBody, body]
() => unwrapForwardedContent(cleanedMessage ?? customBody ?? body),
[cleanedMessage, customBody, body]
);

const isForwarded = useMemo(() => {
Expand All @@ -121,8 +126,9 @@ export function MText({
* For the unwrapping of per-message profile fallbacks, we look for <strong> tags with the data-mx-profile-fallback attribute
*/
const unwrappedPerMessageProfileMessage = useMemo(
() => customBody?.replace(/<strong[^>]*data-mx-profile-fallback[^>]*>(.*?):\s*<\/strong>/i, ''),
[customBody]
() =>
cleanedMessage?.replace(/<strong[^>]*data-mx-profile-fallback[^>]*>(.*?):\s*<\/strong>/i, ''),
[cleanedMessage]
);

const isJumbo = useMemo(() => {
Expand Down Expand Up @@ -189,13 +195,13 @@ export function MText({
return (
<>
<MessageTextBody
preWrap={typeof customBody !== 'string'}
preWrap={typeof cleanedMessage !== 'string'}
jumboEmoji={isJumbo ? jumboEmojiSize : 'none'}
style={style}
>
{renderBody({
body: trimmedBody,
customBody: typeof customBody === 'string' ? customBody : undefined,
customBody: typeof cleanedMessage === 'string' ? cleanedMessage : undefined,
})}
{edited && <MessageEditedContent />}
</MessageTextBody>
Expand Down
Loading