fix: prevent inline links rendering in 2-column grid layout#767
Merged
Conversation
…ten weight - Destructure `node` from react-markdown props to prevent spreading hast AST object onto native <a> elements (React warning + weird attrs) - underline-offset-4 → underline-offset-2: 4px was too far from text at 14px - Remove font-medium: 500 weight made links visually heavier than surrounding text, looked out of place inline
…ine, soften weight" This reverts commit 003c4b7.
The classifyChildren heuristic used `typeof child.type !== 'string'` to detect image elements, but in react-markdown v10 ALL custom components (links, mentions, channel-links, etc.) have function types — not just images. This caused paragraphs with 2+ links to trigger the grid gallery. Fix: mark img component output with `data-block-media` attribute and check for that in classifyChildren instead of the type check. Only actual image/video elements now trigger the grid layout. Tests updated to match the new heuristic.
wesbillman
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Category: fix
User Impact: Links in messages no longer incorrectly render in a 2-column image grid — they display inline as expected.
Problem: When a paragraph contained 2+ links with no surrounding text, the links rendered in a
grid grid-cols-2gallery layout instead of inline. This made link-heavy messages look broken — links appeared side-by-side in boxes rather than flowing naturally in the text.Solution: The
classifyChildrenheuristic usedtypeof child.type !== "string"to detect image elements, but in react-markdown v10 all custom components (links, mentions, channel-links, etc.) have function types — not just images. We now mark actual media output with adata-block-mediaattribute and check for that instead, so only real images/videos trigger the gallery grid.File changes
desktop/src/shared/ui/markdownUtils.ts
Added an
isBlockMedia()helper that checks for thedata-block-mediaprop. Replaced the oldtypeof child.type !== "string"heuristic inclassifyChildrenwith this explicit check so only actual media elements are classified as "image children."desktop/src/shared/ui/markdown.tsx
Wrapped the
imgcomponent's image (lightbox) and video output in<span data-block-media="">so the classification logic can reliably identify them as block media.desktop/src/shared/ui/markdown.test.mjs
Updated all
classifyChildren,isImageOnlyParagraph, andhasBlockMediatests to usedata-block-mediaprops instead of function-type heuristics. Added a new test confirming that React component elements withoutdata-block-media(like links) are correctly classified as non-image.Reproduction Steps
[link1](https://example.com) [link2](https://example.com)main, observe the links render in a 2-column grid layoutScreenshots
Before (main — links misclassified as media, rendering in 2-column grid):

After (fix — links render inline correctly):
