Skip to content

Allow currentIndex to be null in SidebarItems #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Vorkytaka opened this issue Feb 23, 2025 · 3 comments
Open

Allow currentIndex to be null in SidebarItems #554

Vorkytaka opened this issue Feb 23, 2025 · 3 comments
Assignees
Labels
improvement Improvements to existing features

Comments

@Vorkytaka
Copy link

Feature Request:

The SidebarItems widget in the macos_ui package currently requires currentIndex to always be a non-null value between 0 and the total item count, forcing a selection at all times.

Use Case:

When implementing a search function with dynamically updated items, it may be preferable to have no item selected by default (for example, when selected item is out of search). Allowing currentIndex to be null would better reflect an unselected state during such updates.

Proposed Solution:

  1. Enable currentIndex to accept null.
  2. Adjust widget logic to handle the null state so no item is highlighted.
@Adrian-Samoticha Adrian-Samoticha added the improvement Improvements to existing features label Feb 24, 2025
@Adrian-Samoticha
Copy link
Member

Are there any native applications that use the sidebar as a search result list? I believe native apps typically have a search bar that displays search results underneath itself (and I’m quite certain that we provide widgets that implement that as well).

@Vorkytaka
Copy link
Author

While searching for examples, I realized that in addition to the panel under the search bar, there could be a replacement of all content in the sidebar.

For example, in System Settings, when searching, the entire Sidebar starts to change.

Image

I realized that nothing prevents me from implementing something similar with macos_ui in the current form, although I will have to do some tricks.

I still think that the ability to not specify selectedIndex can be useful, but if you disagree you can close the issue.
Thanks.

@Adrian-Samoticha
Copy link
Member

You’re right. The sidebar in the settings app does also allow the user to navigate it using the arrow keys (which works even without any search input). I’m not macos_ui even supports that atm, but it’d be crucial to support when using the sidebar as a search results list.

I’ll assign myself to this issue, though I’m not sure when I’ll find the time to tend to it at the moment.

@Adrian-Samoticha Adrian-Samoticha self-assigned this Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvements to existing features
Projects
None yet
Development

No branches or pull requests

2 participants