fix(details): hoist markdown height so scroll doesn't snap back#614
Conversation
There was a problem hiding this comment.
rainxchzed has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (19)
WalkthroughDetails screen hoists measured heights for About and WhatsNew into DetailsState and reports measurements via new DetailsAction variants; DetailsViewModel stores the maximum observed heights and DetailsRoot wires state and callbacks into refactored About/WhatsNew composables. Localized whatsnew JSON files add a FIXED bullet about scroll-position persistence. ChangesMarkdown Height Measurement State Hoisting
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt (1)
339-353:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winReset
whatsNewMeasuredHeightPxfor all release-switch paths.Line 351 clears measurement in
SelectRelease, butselectReleaseCategory(),retryReleases(), andrefresh()can also changeselectedReleasewithout clearing this field. That can carry stale height into a different release and produce incorrect expand/collapse behavior.Suggested fix
private fun selectReleaseCategory(action: DetailsAction.SelectReleaseCategory) { ... _state.update { it.copy( selectedReleaseCategory = newCategory, selectedRelease = newSelected, installableAssets = installable, primaryAsset = primary, whatsNewTranslation = TranslationState(), + whatsNewMeasuredHeightPx = null, ) } }// In retryReleases()/refresh(), clear when selected release identity changes val oldId = _state.value.selectedRelease?.id val newId = selected?.id // or selectedRelease?.id ... whatsNewMeasuredHeightPx = if (oldId != newId) null else it.whatsNewMeasuredHeightPx🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt` around lines 339 - 353, The state field whatsNewMeasuredHeightPx is only cleared in the DetailsAction.SelectRelease branch but not when selectedRelease is changed via selectReleaseCategory(), retryReleases(), or refresh(), which can leave a stale height; update those code paths (selectReleaseCategory, retryReleases, refresh) to compare previous selectedRelease?.id with the new selected release id and set whatsNewMeasuredHeightPx = null when the id changed (otherwise keep the existing value), mirroring the behavior in the SelectRelease handling where you call recomputeAssetsForRelease and update selectedRelease/primaryAsset/etc.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt`:
- Around line 339-353: The state field whatsNewMeasuredHeightPx is only cleared
in the DetailsAction.SelectRelease branch but not when selectedRelease is
changed via selectReleaseCategory(), retryReleases(), or refresh(), which can
leave a stale height; update those code paths (selectReleaseCategory,
retryReleases, refresh) to compare previous selectedRelease?.id with the new
selected release id and set whatsNewMeasuredHeightPx = null when the id changed
(otherwise keep the existing value), mirroring the behavior in the SelectRelease
handling where you call recomputeAssetsForRelease and update
selectedRelease/primaryAsset/etc.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: eabdbc83-7795-490c-a1ce-a985ef51373a
📒 Files selected for processing (19)
core/presentation/src/commonMain/composeResources/files/whatsnew/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/ar/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/bn/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/es/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/fr/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/hi/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/it/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/ja/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/ko/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/pl/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/ru/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/tr/18.jsoncore/presentation/src/commonMain/composeResources/files/whatsnew/zh-CN/18.jsonfeature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsAction.ktfeature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsRoot.ktfeature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsState.ktfeature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.ktfeature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/sections/About.ktfeature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/sections/WhatsNew.kt
There was a problem hiding this comment.
rainxchzed has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
rainxchzed has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
ba67292 to
c32b34d
Compare
There was a problem hiding this comment.
rainxchzed has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
README / What's-new sections snapped to the top after scrolling past and back. Cause:
ExpandableMarkdownContentheld measured height inremember, which LazyColumn disposed when the item left the viewport buffer. On re-entry the composable started withcontentHeightPx = 0f→needsExpansion = false→ full-height render →onGloballyPositionedmeasured → flipped to clipped → layout reflow under the user's finger.Fix:
aboutMeasuredHeightPx+whatsNewMeasuredHeightPxonDetailsState.OnAboutMeasured/OnWhatsNewMeasuredactions, monotonic update in VM.about()/whatsNew()take measured + callback as parameters;ExpandableMarkdownContentreads measured from props instead of localremember.item(key = ...)for both markdown blocks so LazyColumn restores them deterministically.AnimatedContent(was recomposing the whole subtree on every translation toggle).Test plan
Summary by CodeRabbit