Mouse-wheel scrolling leaves a Timebox draft unsaved
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- Half a day
- Newbie friendliness
- 65/100
Research direction
Run the new regression test in AnkiDroid/src/test/java/com/ichi2/anki/preferences/TimeboxMouseScrollRegressionTest.kt; it sets up TimeboxSettingsScreen with TimeboxSettingsViewModel, performs a mouse-wheel scroll, and expects CollectionPreferences.getTimeboxTimeLimit() to reflect the typed draft. Then trace where the focused minutes field commits its draft in the screen and view model, and why scrolling bypasses that commit. Done when this regression test passes and the existing Timebox settings tests still pass.
Written by the indexing model from the issue text.
Description
Subject: Mouse-wheel scrolling leaves a Timebox draft unsaved
Scrolling Timebox with a mouse wheel can leave a focused draft uncommitted.
---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/preferences/TimeboxMouseScrollRegressionTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/preferences/TimeboxMouseScrollRegressionTest.kt
new file mode 100644
index 0000000000..b19379b646
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/preferences/TimeboxMouseScrollRegressionTest.kt
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.preferences
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.runtime.collectAsState
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.semantics.SemanticsProperties
+import androidx.compose.ui.test.SemanticsMatcher
+import androidx.compose.ui.test.assertIsFocused
+import androidx.compose.ui.test.hasSetTextAction
+import androidx.compose.ui.test.junit4.v2.createComposeRule
+import androidx.compose.ui.test.performClick
+import androidx.compose.ui.test.performMouseInput
+import androidx.compose.ui.test.performTextReplacement
+import androidx.compose.ui.unit.dp
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.ichi2.anki.RobolectricTest
+import com.ichi2.anki.utils.CollectionPreferences
+import com.ichi2.compose.theme.AnkiDroidTheme
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import kotlin.test.assertEquals
+import kotlin.time.Duration.Companion.minutes
+
+@RunWith(AndroidJUnit4::class)
+class TimeboxMouseScrollRegressionTest : RobolectricTest() {
+ @get:Rule
+ val composeRule = createComposeRule()
+
+ @Test
+ fun `scrolling Timebox with a mouse wheel commits the draft`() =
+ runTest {
+ CollectionPreferences.setTimeboxTimeLimit(20.minutes)
+ val viewModel = TimeboxSettingsViewModel()
+ advanceRobolectricLooper()
+ composeRule.setContent {
+ val state by viewModel.uiState.collectAsState()
+ AnkiDroidTheme {
+ Box(Modifier.fillMaxWidth().height(285.dp)) {
+ TimeboxSettingsScreen(
+ isLoading = state.isLoading,
+ isEnabled = state.isEnabled,
+ minutes = state.limit.minutes,
+ onToggleEnabled = viewModel::toggleEnabled,
+ onIncrement = viewModel::increment,
+ onDecrement = viewModel::decrement,
+ onSetMinutes = viewModel::setMinutes,
+ onNavigateUp = {},
+ )
+ }
+ }
+ }
+
+ val input = composeRule.onNode(hasSetTextAction())
+ input.performClick()
+ input.performTextReplacement("45")
+ input.assertIsFocused()
+
+ val pane = composeRule.onNode(SemanticsMatcher.keyIsDefined(SemanticsProperties.VerticalScrollAxisRange))
+ val scrollRange = pane.fetchSemanticsNode().config[SemanticsProperties.VerticalScrollAxisRange]
+ val previousPosition = scrollRange.value()
+ pane.performMouseInput {
+ moveTo(center)
+ scroll(3f)
+ }
+ composeRule.waitUntil(2_000) { scrollRange.value() > previousPosition }
+ advanceRobolectricLooper()
+
+ assertEquals(45.minutes, CollectionPreferences.getTimeboxTimeLimit())
+ }
+}
- Originally posted by @david-allison in #22858
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 320
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
ankidroid/Anki-Android#23798 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ankidroid/Anki-Android#23797 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23786 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ankidroid/Anki-Android#23756 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ankidroid/Anki-Android#23755 ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sorsama/deepseek-harness-mobile#154 ·
Maintainers usually reply within 1 day
-
0. Needs triage enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
[Feature] 3D and AR on phones (Filament, ARCore, SceneView): current APIs instead of 2022-era codeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 4 days
-
unshaved-yak
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
accessibility agent-ready area:android bug fleet
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
level-98/mailcrane#412 · 1 comment ·
Maintainers usually reply within 1 day