Skip to content

Conversation

@hafizrahman
Copy link
Contributor

@hafizrahman hafizrahman commented Dec 31, 2024

Closes: #13218, #13231

Description

This PR adds various fixes and updates to the code so that:

  1. Selection state persists after configuration changes (e.g: theme changes, layout changes)
  2. Selection state persists after loading more items by scrolling down.

Steps to reproduce

TC 1: Config change

  1. Run app, go to Orders, then long press an Order to enable bulk selection mode and select some more items.
  2. Toggle device's dark/light mode. The selection state should persist (toolbar shows same number of items, correct Orders are checked)
  3. Rotate device from portait to landscape, the selection should persist.
  4. Go back to portrait, the selection should persist.

TC 2: Load more

  1. Need a test site with many Orders on this (ideally 100 or more),
  2. Run app, go to Orders, do pull to refresh to ensure not all items are loaded yet
  3. Long press an Order to enable bulk selection mode and select some more items.
  4. Scroll way down until the load more animation and behavior are triggered.
  5. Once more Orders are loaded, ensure that selection state persists (toolbar shows same number of items, correct Orders are checked)

Testing information

The tests that have been performed

Tested this both on phone and tablet simulator for both TCs.

Images/gif

Videos incoming.

  • 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.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 31, 2024

📲 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 Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit5639575
Direct Downloadwoocommerce-wear-prototype-build-pr13227-5639575.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 31, 2024

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

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit5639575
Direct Downloadwoocommerce-prototype-build-pr13227-5639575.apk

@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 40.60%. Comparing base (4d54483) to head (5639575).
Report is 94 commits behind head on trunk.

Files with missing lines Patch % Lines
...android/ui/orders/OrderSelectionItemKeyProvider.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #13227   +/-   ##
=========================================
  Coverage     40.59%   40.60%           
+ Complexity     6372     6371    -1     
=========================================
  Files          1345     1345           
  Lines         77334    77325    -9     
  Branches      10617    10615    -2     
=========================================
- Hits          31396    31394    -2     
+ Misses        43177    43169    -8     
- Partials       2761     2762    +1     

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

@hafizrahman hafizrahman changed the title [Bulk Update Orders] Persist selection on configuration change [Bulk Update Orders] Persist selection on configuration change and load more Jan 2, 2025
@hafizrahman hafizrahman added type: task An internally driven task. feature: order details Related to order details. labels Jan 2, 2025
@hafizrahman hafizrahman added this to the 21.4 milestone Jan 2, 2025
@hafizrahman hafizrahman marked this pull request as ready for review January 2, 2025 15:21
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.

Good job @hafizrahman. The solutions we worked on seem to be working in all cases. I'll pre-approve, while we still discuss with Hicham about possible cleaner options 👍🏼

Comment on lines +235 to +250
// Some edge cases in order selection mode, like tapping the screen with 4 fingers or using TalkBack,
// cause the order's onClick listener to gain focus over the selection tracker.
// This quick fix will prevent the app from entering an unexpected status when the app is in selection mode.
private fun shouldPreventDetailNavigation(orderId: Long): Boolean {
if (tracker?.selection?.size() != 0) {
tracker?.let { selectionTracker ->
if (selectionTracker.isSelected(orderId)) {
selectionTracker.deselect(orderId)
} else {
selectionTracker.select(orderId)
}
}
return true
}
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just moving this function out of OrderListFragment to call it exactly when is needed and avoid unwanted side effects.

@hafizrahman
Copy link
Contributor Author

Thanks! @JorgeMucientes

I'll merge this once the target is trunk

@hafizrahman hafizrahman added status: do not merge Dependent on another PR, ready for review but not ready for merge. feature: order list Related to the order list. and removed feature: order details Related to order details. labels Jan 3, 2025
Base automatically changed from task/13140-connect-bulk-update-func to trunk January 3, 2025 09:33
@hafizrahman hafizrahman removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Jan 3, 2025
@hafizrahman hafizrahman merged commit 37c5583 into trunk Jan 3, 2025
19 of 20 checks passed
@hafizrahman hafizrahman deleted the task/bulk-order-config-change branch January 3, 2025 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: order list Related to the order list. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist selection state on configuration change

5 participants