pdf: remember FocusRequester in chrome test compositions
- Commit
b089be20d1fb5c694a34993759b84e9057a2ba1c- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-08 06:24 UTC (28 days ago)
- Parents
83354bc
What: wrap the three inline FocusRequester() searchFocus arguments in
ChromeAndFormsTest with remember { }, plus the remember import.
Why: :pdf:lintDev failed on 3 RememberInComposition errors — calling a
@RememberInComposition-annotated declaration (FocusRequester constructor)
inside composition without using remember.
Root cause: same family as the Animatable/FocusRequester-class fixes
earlier in this drive — constructing the requester inline recreates it on
every recomposition, which would drop pending focus requests. These tests
never trigger recomposition, so it only tripped the lint gate.
Rejected alternatives: hoisting to a shared val before setContent (the
three tests each need their own instance; remember { } keeps the instance
scoped to its composition with a one-token change per site); lint
suppression (hides a real recomposition hazard).
User-visible effect: none; test-only change.
Verification: :pdf:lint green, :pdf:testDevUnitTest 277/0/0.Diff
pdf/src/test/java/com/vayunmathur/pdf/ui/ChromeAndFormsTest.kt
diff --git a/pdf/src/test/java/com/vayunmathur/pdf/ui/ChromeAndFormsTest.kt b/pdf/src/test/java/com/vayunmathur/pdf/ui/ChromeAndFormsTest.ktindex 59ca159b57..64cf6b876f 100644--- a/pdf/src/test/java/com/vayunmathur/pdf/ui/ChromeAndFormsTest.kt+++ b/pdf/src/test/java/com/vayunmathur/pdf/ui/ChromeAndFormsTest.kt@@ -2,6 +2,7 @@ package com.vayunmathur.pdf.ui import android.content.Context import android.net.Uri+import androidx.compose.runtime.remember import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.geometry.Offset import androidx.compose.ui.test.assertIsDisplayed@@ -93,7 +94,7 @@ class ChromeAndFormsTest { scroll = SafePdfScrollState(), zoom = SafePdfZoomState(), drawerState = rememberDrawerState(DrawerValue.Closed), pageViewer = { androidx.compose.foundation.layout.Box(it) { com.vayunmathur.library.ui.Text("PagesHere") } },- searchFocus = FocusRequester(), onBack = {}, onShare = {}, onSaveInPlace = {}, onSaveCopyName = {},+ searchFocus = remember { FocusRequester() }, onBack = {}, onShare = {}, onSaveInPlace = {}, onSaveCopyName = {}, ) } }@@ -113,7 +114,7 @@ class ChromeAndFormsTest { scroll = SafePdfScrollState(), zoom = SafePdfZoomState(), drawerState = rememberDrawerState(DrawerValue.Closed), pageViewer = { androidx.compose.foundation.layout.Box(it) {} },- searchFocus = FocusRequester(), onBack = {}, onShare = {}, onSaveInPlace = {}, onSaveCopyName = {},+ searchFocus = remember { FocusRequester() }, onBack = {}, onShare = {}, onSaveInPlace = {}, onSaveCopyName = {}, ) } }@@ -133,7 +134,7 @@ class ChromeAndFormsTest { scroll = SafePdfScrollState(), zoom = SafePdfZoomState(), drawerState = rememberDrawerState(DrawerValue.Closed), pageViewer = { androidx.compose.foundation.layout.Box(it) {} },- searchFocus = FocusRequester(), onBack = {}, onShare = {}, onSaveInPlace = {}, onSaveCopyName = {},+ searchFocus = remember { FocusRequester() }, onBack = {}, onShare = {}, onSaveInPlace = {}, onSaveCopyName = {}, ) } }