Skip to content

Conversation

@AdamGrzybkowski
Copy link
Contributor

Closes WOOMOB-1347

Description

This PR adds the Discard changes dialog to the BookingNoteScreen after tapping the back button.

If there are unsaved changes, the dialog is presented with the option to discard them.

Test Steps

  1. Make sure you have the latest booking plugin installed
  2. Launch the app
  3. Bo to bookings tab
  4. Tap on a booking
  5. Scroll down to the notes section
  6. Tap on it
  7. Tap back button
  8. Confirm the screen was closed
  9. Open the note again
  10. Add changes
  11. Tap back button
  12. Confirm the dialog was shown

Images/gif

Screen_recording_20251023_090007.mp4
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a discard changes confirmation dialog for the BookingNoteScreen. When users attempt to navigate back after making unsaved changes to a booking note, they are prompted to confirm whether they want to discard those changes.

Key Changes:

  • Added dialog state management to BookingNoteViewModel to track and control the discard changes dialog
  • Implemented back button handling logic that compares current note content with initial state to determine if changes exist
  • Added comprehensive test coverage for back button behavior including scenarios with no changes, with changes, during save operations, and dialog interactions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
BookingNoteViewModelTest.kt Added 4 test cases covering back button behavior and dialog interactions
strings.xml Added dialog message and button text resources
BookingNoteViewState.kt Added onBackPressed callback and dialogState field
BookingNoteViewModel.kt Implemented back press logic with change detection and dialog state management
BookingNoteScreen.kt Connected back button to ViewModel's onBackPressed and added dialog rendering
BookingNoteFragment.kt Removed redundant onBack parameter as back navigation is now handled via Exit event

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 23, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit525fcf4
Direct Downloadwoocommerce-wear-prototype-build-pr14804-525fcf4.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 23, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit525fcf4
Direct Downloadwoocommerce-prototype-build-pr14804-525fcf4.apk

@AdamGrzybkowski AdamGrzybkowski force-pushed the issue/WOOMOB-1347_add_note_discard_changes branch from c14968a to 525fcf4 Compare October 23, 2025 08:30
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.18%. Comparing base (fced2f1) to head (525fcf4).
⚠️ Report is 83 commits behind head on trunk.

Files with missing lines Patch % Lines
...e/android/ui/bookings/note/BookingNoteViewModel.kt 92.85% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14804      +/-   ##
============================================
+ Coverage     38.17%   38.18%   +0.01%     
- Complexity    10072    10078       +6     
============================================
  Files          2132     2132              
  Lines        120294   120322      +28     
  Branches      16447    16450       +3     
============================================
+ Hits          45920    45945      +25     
  Misses        69750    69750              
- Partials       4624     4627       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JorgeMucientes JorgeMucientes self-assigned this Oct 23, 2025
Copy link
Contributor

@JorgeMucientes JorgeMucientes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great and code looks good :shipit:

@AdamGrzybkowski AdamGrzybkowski merged commit 73740f5 into trunk Oct 24, 2025
16 checks passed
@AdamGrzybkowski AdamGrzybkowski deleted the issue/WOOMOB-1347_add_note_discard_changes branch October 24, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants