Skip to content

fix: select remaining item when deleting second-of-two requests (#1710)#1716

Open
deepak0x wants to merge 1 commit into
foss42:mainfrom
deepak0x:fix/1710-remove-selection
Open

fix: select remaining item when deleting second-of-two requests (#1710)#1716
deepak0x wants to merge 1 commit into
foss42:mainfrom
deepak0x:fix/1710-remove-selection

Conversation

@deepak0x

@deepak0x deepak0x commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

PR Description

remove() in lib/providers/collection_providers.dart used itemIds.length > 1 to 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 to false and newId fell through to null — 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 correct removeEnvironment logic in environment_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 null on the old code, passes with the fix).

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Tests verified locally: flutter test test/providers/collection_providers_test.dartAll tests passed! (35 tests, incl. the 3 new ones). Run on Flutter 3.41.x to match the repo's pubspec constraint (flutter: ">=3.41.2"), since extended_text_field 16.0.2 does not compile against Flutter 3.44.x.

Added/updated tests?

  • Yes

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

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
@deepak0x deepak0x force-pushed the fix/1710-remove-selection branch from 30d6033 to a7dd162 Compare June 30, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Deleting second-of-two requests leaves selection null

1 participant