fix: select remaining item when deleting second-of-two requests (#1710)#1716
Open
deepak0x wants to merge 1 commit into
Open
fix: select remaining item when deleting second-of-two requests (#1710)#1716deepak0x wants to merge 1 commit into
deepak0x wants to merge 1 commit into
Conversation
remove() used itemIds.length > 1 to decide whether to select the previous item after a deletion. Deleting the non-first request of a 2-item collection left 1 item, making the guard false so newId fell through to null and the sidebar deselected everything / the main panel went blank even though a request remained. Replace the guard with idx > 0, mirroring removeEnvironment in environment_providers.dart. Add regression tests for deleting the second-of-two, first-of-two, and only request. Closes foss42#1710
30d6033 to
a7dd162
Compare
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.
PR Description
remove()inlib/providers/collection_providers.dartuseditemIds.length > 1to decide whether to select the previous item after a deletion. When a 2-item collection had its non-first request deleted, only 1 item remained, so the guard evaluated tofalseandnewIdfell through tonull— the sidebar deselected everything and the main panel went blank even though a request still existed.Fix: replace the guard with
idx > 0, mirroring the equivalent and correctremoveEnvironmentlogic inenvironment_providers.dart.Also adds regression tests covering deletion of the second-of-two, first-of-two, and the only request. The second-of-two test reproduces the bug exactly (selection becomes
nullon the old code, passes with the fix).Related Issues
Checklist
mainbranch before making this PRflutter upgradeand verify)flutter test) and all tests are passingAdded/updated tests?
OS on which you have developed and tested the feature?