Skip to content

Fix LoadingList::selected() to return item reference#114

Open
ryanoneill wants to merge 2 commits intomainfrom
fix/loading-list-selected-api
Open

Fix LoadingList::selected() to return item reference#114
ryanoneill wants to merge 2 commits intomainfrom
fix/loading-list-selected-api

Conversation

@ryanoneill
Copy link
Owner

Summary

  • Rename selected()selected_index() (returns Option<usize>)
  • Add new selected()Option<&LoadingListItem<T>> consistent with Tabs, RadioGroup pattern
  • Make selected_item() an alias for selected()
  • Update all ~27 test call sites from selected() to selected_index()
  • Add test_selected_returns_item test

Context

Every other Envision component's selected() returns an item reference (Option<&T>). LoadingList was the outlier, returning Option<usize>. The index-returning method is still available as selected_index().

Test plan

  • All 75 LoadingList unit tests pass
  • 3 doc tests pass (including new doc test on selected())
  • cargo clippy --all-targets --all-features -- -D warnings clean

🤖 Generated with Claude Code

@codecov-commenter
Copy link

codecov-commenter commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.64%. Comparing base (e096986) to head (3eaee83).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #114   +/-   ##
=======================================
  Coverage   92.64%   92.64%           
=======================================
  Files         100      100           
  Lines        9545     9547    +2     
=======================================
+ Hits         8843     8845    +2     
  Misses        702      702           

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

Rename the old selected() -> Option<usize> to selected_index() and add
a new selected() -> Option<&LoadingListItem<T>> for consistency with
other Envision components (Tabs, RadioGroup) that return item references
from their selected() method.

- Rename selected() to selected_index() (returns Option<usize>)
- Add selected() returning Option<&LoadingListItem<T>>
- Make selected_item() an alias for selected()
- Update all test call sites (~27) from selected() to selected_index()
- Add test_selected_returns_item test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ryanoneill ryanoneill force-pushed the fix/loading-list-selected-api branch from 917afaa to 5e2f43f Compare March 2, 2026 16:45
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants