Repository navigation
fix(android): keep media slot heights when Yoga snaps the view wider - #4
Merged
juliusmarminge merged 3 commits intoOct 15, 2026
Conversation
Yoga measures the markdown view at its unrounded width, then snaps the measured node outward to whole pixels (floor left, ceil right), so the laid-out view can be up to 2px wider than the width the measure pass saw. React measures each media slot at that laid-out width. The measure pass rejected those overrides whenever the gap reached 0.5dp (for example 970.3px measured vs 972px laid out at 2.8125x) and sized the document from the 16:9 fallback, while the view drew the real heights. Captioned images then overlapped the following content and the message footer. Allow the 2px snap on top of the existing 0.5dp tolerance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
2 tasks done
Member
|
Taking over this one to land it in the fork and ship it in T3 Code. I'll keep you credited and post what changed here. |
…al measure path Replaces the parameter-only test with a MediaSlotView.heightPx test at 2.8125x that fails without the tolerance, and applies the same 2px allowance to ENRMMediaSlotHeight, which had the identical 0.5pt check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What/Why?
On Android, React-rendered media slots (T3 Code's captioned markdown images) overlap the content after them on some densities. Reported in pingdotgg/t3code#19914.
The cause is a width mismatch between measurement and layout:
MediaSlot.heightForWidthonly accepted a measured height within 0.5dp of the requested width.MediaSlotViewdrew the real heights.The fix:
heightForWidthtakes a width tolerance.MediaSlotView.heightPxpasses 0.5dp plus 2px. It is the one place all three Android measure paths go through: the root measure pass, segment heights, and the view'sonMeasure.Takeover changes (by @juliusmarminge, on top of @voida6's fix):
ENRMMediaSlotHeighthad the identical 0.5pt check against the same pixel-snapped width. It now allows 1.5pt, which is 0.5pt plus 2px at 2x, and covers 3x as well.heightForWidth, so it still passed with the fix removed. It is replaced byMediaSlotViewTest, which callsMediaSlotView.heightPxat 2.8125x with the logged widths. It fails without the tolerance and passes with it.Upstream: none. Media slots exist only in this fork. Upstream closed those PRs in favour of designing media rendering themselves (software-mansion#54), so this goes away when the fork moves to their version.
Testing
:react-native-enriched-markdown:testDebugUnitTest(all suites) andktlintCheckpass.MediaSlotViewTestfails with theMediaSlotViewtolerance removed and passes with it.mediaOverrideForFramecompares two widths taken after layout, so it was never the rejecting gate).Originally reported and fixed by @voida6 in this PR.