Fix toolbar back arrow discarding unsaved changes in File Editor#421
Open
faraz152 wants to merge 1 commit intoFossifyOrg:mainfrom
Open
Fix toolbar back arrow discarding unsaved changes in File Editor#421faraz152 wants to merge 1 commit intoFossifyOrg:mainfrom
faraz152 wants to merge 1 commit intoFossifyOrg:mainfrom
Conversation
The toolbar navigation arrow (set by setupTopAppBar) was calling finish() directly, bypassing onBackPressedCompat() which contains the unsaved changes dialog. Now the navigation click listener routes through onBackPressedDispatcher so the save/discard prompt is shown consistently for both the system back gesture and the toolbar arrow. Fixes FossifyOrg#362 Co-Authored-By: Claude Opus 4.6 <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.
Summary
ReadTextActivity) was callingfinish()directly viasetupTopAppBar, bypassing the unsaved changes dialog shown byonBackPressedCompat()setupTopAppBarto route throughonBackPressedDispatcher.onBackPressed(), ensuring the save/discard prompt appears for both the system back gesture and the toolbar arrowChanges
ReadTextActivity.kt— AddedsetNavigationOnClickListeneraftersetupTopAppBarinonResume()to delegate toonBackPressedDispatcherHow it works
onBackPressedCompat()already handles:Previously, only the system back button/gesture triggered this flow. The toolbar arrow called
finish()directly (set bysetupTopAppBarin fossify-commons), so edits were silently discarded.Now both paths go through
onBackPressedDispatcher.onBackPressed()→onBackPressedCompat().Test plan
compileFossDebugKotlin)🤖 Generated with Claude Code