[JEWEL-938] Split SelectableLazyColumn into Single/Multi APIs and add initial selected keys support#3450
Conversation
nebojsa-vuksic
commented
Mar 6, 2026
| f:org.jetbrains.jewel.foundation.lazy.SelectableLazyListStateKt | ||
| - sf:getVisibleItemsRange(androidx.compose.foundation.lazy.LazyListState):kotlin.ranges.IntRange | ||
| - sf:getVisibleItemsRange(org.jetbrains.jewel.foundation.lazy.SelectableLazyListState):kotlin.ranges.IntRange | ||
| - sf:rememberSelectableLazyListState(I,I,androidx.compose.runtime.Composer,I,I):org.jetbrains.jewel.foundation.lazy.SelectableLazyListState |
Collaborator
Author
There was a problem hiding this comment.
The rememberSelectableLazyListState 2-args function is depricated
fun rememberSelectableLazyListState(
initialFirstVisibleItemIndex: Int = 0,
initialFirstVisibleItemScrollOffset: Int = 0,
)in favor of rememberSelectableLazyListState 4-args function:
public fun rememberSingleSelectionLazyListState(
initialFirstVisibleItemIndex: Int = 0,
initialFirstVisibleItemScrollOffset: Int = 0,
initialSelectedKey: Any? = null,
)ef805e1 to
fb0e75d
Compare
… initial selected keys support - Split SelectableLazyColumn into new typed entry points `SingleSelectionLazyColumn` and `MultiSelectionLazyColumn`, each bound to the correct selection mode through dedicated state types. - Add support for initializing legacy and new states with preselected keys (`initialSelectedKeys` / `initialSelectedKey`) without triggering `onSelectedIndexesChange` on first composition. - Extend `SelectableLazyListState` with `selectionMode` and `initialSelectedKeys` metadata used for legacy compatibility paths and mismatch diagnostics. - Preserve source and binary compatibility by keeping legacy `SelectableLazyColumn` and `rememberSelectableLazyListState` overloads, with migration-focused deprecations. - Preserve legacy precedence contract where the explicit ` selectionMode ` parameter wins over `state.selectionMode` and emits warnings on mismatches instead of throwing or mutating state during composition. - Add tests for typed states, typed columns, remember overload normalization, legacy mismatch scenarios, and multi-selection keyboard edge cases. Signed-off-by: Nebojsa.Vuksic <nebojsa.vuksic@jetbrains.com>
fb0e75d to
1133634
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.
Summary
This PR splits Jewel
SelectableLazyColumninto explicit single-selection and multi-selection APIs (SingleSelectionLazyColumn,MultiSelectionLazyColumn) and adds support for initial selected keys during state creation, while preserving legacy API behavior andcompatibility.
Dependency
This PR depends on #3446 and should be merged only after that PR lands. Until then, the PR stays in draft mode.
Changes
SingleSelectionLazyColumnandMultiSelectionLazyColumnas new composable entry points.SingleSelectionLazyListStateandMultiSelectionLazyListState.rememberSingleSelectionLazyListState(initialSelectedKey = ...)rememberMultiSelectionLazyListState(initialSelectedKeys = ...)SelectableLazyListStatewithselectionModeandinitialSelectedKeysmetadata used in legacy compatibility scenarios.SelectableLazyColumn/rememberSelectableLazyListStateAPIs for source and binary compatibility and marked migration path with deprecations.rememberSelectableLazyListState(firstVisibleItemIndex, firstVisibleItemScrollOffset)and directed users to the 4-arg overload.onSelectedIndexesChange.Edge cases and behavior details
selectionMode=SelectionMode.Singlewith legacy state containing multiple selected keys.SelectionMode.Single.SelectionMode.Nonewith legacy state already containing selected keys.SelectionMode.Nonesemantics.SelectionMode.Nonedrops all initial keys.SelectionMode.Singlekeeps first key from list order.SelectionMode.Multiplekeeps all keys, deduplicated in insertion order.Why new APIs and why keep old ones
Release notes
New features
SingleSelectionLazyColumnandMultiSelectionLazyColumnwith dedicated typed state and remember APIs.initialSelectedKey/initialSelectedKeys).Bug fixes
Deprecated API
SelectableLazyColumnentry points in favor of explicit single/multi APIs while preservingcompatibility overloads.
rememberSelectableLazyListState(...); use the 4-arg overload.