Repository navigation
タッチ不可モード中は画面横スワイプと戻る操作による前画面への遷移も防止 - #6648
Conversation
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V3xe2qbYY2puA7zW3MzZqh
📝 WalkthroughWalkthroughアンタッチャブルモード中のiOS戻るジェスチャーとAndroid戻る操作を抑止します。状態取得用atom、公開フック、Main画面への副作用ホスト、テスト、英語・日本語の説明文を追加します。 Changesアンタッチャブルモード操作制御
Estimated code review effort: 3 (Moderate) | ~20分 Sequence Diagram(s)sequenceDiagram
participant MainScreenEffects
participant usePreventBackInUntouchableMode
participant BackHandler
MainScreenEffects->>usePreventBackInUntouchableMode: Androidでフックを実行
usePreventBackInUntouchableMode->>BackHandler: hardwareBackPressを購読
BackHandler-->>usePreventBackInUntouchableMode: 戻るイベント
usePreventBackInUntouchableMode-->>BackHandler: trueを返して抑止
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/stacks/MainStack.test.tsx (1)
64-64: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift走行画面まで含む結合テストを追加してください。
src/stacks/MainStack.test.tsxはMainを空コンポーネントへ置換します。src/hooks/usePreventBackInUntouchableMode.test.tsxはフックだけを直接実行します。そのため、実際のMainのFxPreventBackInUntouchableModeが同じストア状態に応じてBackHandlerを登録・解除する経路を検証しません。
src/stacks/MainStack.test.tsx#L64-L64: 実際のMain側の副作用ホストを通す結合シナリオを追加してください。src/hooks/usePreventBackInUntouchableMode.test.tsx#L22-L22: 単体テストは維持し、走行画面との結合シナリオで状態変更時の登録と解除を検証してください。As per coding guidelines, “Test agents in isolation and with integration tests to ensure correctness and compatibility”.
🤖 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 `@src/stacks/MainStack.test.tsx` at line 64, src/stacks/MainStack.test.tsx:64-64でMainのモックを外すか実際の副作用ホストを通す結合シナリオを追加し、同じストア状態の変更に応じて走行画面のFxPreventBackInUntouchableModeがBackHandlerを登録・解除することを検証してください。src/hooks/usePreventBackInUntouchableMode.test.tsx:22-22のフック単体テストは維持し、既存の単体検証を削除・置換しないでください。Source: Coding guidelines
🤖 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.
Inline comments:
In `@assets/translations/en.json`:
- Line 197: Update the untouchableModeEnabledNotice translation to mention that
screen-edge swipes and the back gesture are disabled, matching
untouchableModeDescription. Apply this change in
assets/translations/en.json:197-197 and assets/translations/ja.json:198-198.
In `@src/stacks/MainStack.test.tsx`:
- Around line 104-107: Update the MainStack test suite’s lifecycle hooks to add
an afterEach callback that calls jest.clearAllMocks(), while preserving the
existing beforeEach reset of screenProps.length.
---
Nitpick comments:
In `@src/stacks/MainStack.test.tsx`:
- Line 64:
src/stacks/MainStack.test.tsx:64-64でMainのモックを外すか実際の副作用ホストを通す結合シナリオを追加し、同じストア状態の変更に応じて走行画面のFxPreventBackInUntouchableModeがBackHandlerを登録・解除することを検証してください。src/hooks/usePreventBackInUntouchableMode.test.tsx:22-22のフック単体テストは維持し、既存の単体検証を削除・置換しないでください。
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4427a8bb-c7d7-468d-beee-af56d11d4be1
📒 Files selected for processing (9)
assets/translations/en.jsonassets/translations/ja.jsonsrc/hooks/index.tssrc/hooks/usePreventBackInUntouchableMode.test.tsxsrc/hooks/usePreventBackInUntouchableMode.tssrc/screens/Main.tsxsrc/stacks/MainStack.test.tsxsrc/stacks/MainStack.tsxsrc/store/atoms/tuning.ts
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V3xe2qbYY2puA7zW3MzZqh
|
CodeRabbit の指摘に対応しました( 対応済み(2 件)
対応見送り(nitpick 1 件): 実際の 今回は見送ります。理由は次の 2 点です。
結合レベルの検証が必要という判断であれば、 なお、この変更はネイティブジェスチャーの挙動を含むため、iOS のスワイプバックと Android の戻るジェスチャーは実機・シミュレータでの確認をお願いします(作業環境にビルド手段がないため未実施です)。 ローカル検証: Generated by Claude Code |
概要
タッチ不可モードが有効なとき、タップだけでなく「画面横スワイプ(iOS のスワイプバック)」と「Android の戻るキー・戻るジェスチャー」による走行画面からの離脱も防ぐようにしました。従来はタッチ不可モード中でも横スワイプ 1 回で路線選択画面へ戻れてしまい、ポケットやカバンの中での誤操作防止という本来の目的を満たせていませんでした。
変更の種類
変更内容
MainStackの Main 画面にgestureEnabled: !untouchableModeEnabledを設定し、iOS の画面端スワイプバックをネイティブごと無効化usePreventBackInUntouchableModeを追加し、Android の戻るキー・戻るジェスチャーをBackHandlerで握りつぶす(useIsFocused()でゲートしているため、上に積まれた画面からは通常どおり戻れる)Main.tsxのレンダーレス副作用ホストMainScreenEffectsにFxPreventBackInUntouchableModeとして、iOS では発火しないため Android 限定でマウントuntouchableModeEnabledAtom(派生 atom)を追加し、MainStackが他のチューニング値の更新で再レンダーされないようにしたuntouchableModeDescriptionとuntouchableModeEnabledNoticeを、タップに加えて画面端スワイプ・戻る操作も無効になる旨へ更新usePreventBackInUntouchableModeとMainStack(gestureEnabledの切り替え)のユニットテストを追加設計上の判断
一律に
beforeRemove/usePreventRemoveで離脱をブロックする方法は採りませんでした。beforeRemoveはネストした画面にも伝播するため、ディープリンクやクイックアクション由来のCommonActions.reset(src/utils/navigateToSelectLine.ts)まで巻き込んでしまい、誤操作ではない遷移まで止まってしまいます。今回はスワイプ/戻る操作という「誤操作の入口」だけを塞ぐ実装にしています。Main のbeforeRemoveによるresetMainStateはpreventDefaultしていないため、既存の状態リセット挙動もそのままです。リグレッションリスクと緩和策
gestureEnabledは!untouchableModeEnabledで切り替え。OFF 時にtrueになることをMainStack.test.tsxで検証useIsFocused()で走行画面が前面のときだけ購読。フォーカス喪失時に購読しないことをテストで検証beforeRemoveを使わず戻る操作のみを対象にしたため、プログラムによるreset/replace遷移は従来どおりsubscription.remove()することをテストで検証テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ることローカルで実行したコマンドと結果:
実機・シミュレータでの動作確認は未実施です(ビルド手段のない環境で作業したため)。iOS のスワイプバックと Android の戻るジェスチャーの実挙動は端末での確認をお願いします。
関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
新機能
テスト