[JEWEL-1284] Fix SelectableLazyColumn to respect SelectionMode.None and prevent unintended selection#3446
Conversation
656ba70 to
0a5e48d
Compare
|
@nebojsa-vuksic looks like the ticket number is wrong, it is JEWEL-1284 I guess |
@daaria-s Indeed, it's a wrong ticket number 🤦 I need to update id in the commit as well. Thanks for pointing this our 🙏 |
…nd prevent unintended selection - Update KeyActions to skip selection when `SelectionMode` is set to `None`. - Adjust `SelectableLazyColumn` to avoid auto-selecting items in `None` mode, even on initial focus. - Add test coverage for `SelectionMode.None` to ensure no selection occurs on click or focus. Signed-off-by: Nebojsa.Vuksic <nebojsa.vuksic@jetbrains.com>
0a5e48d to
e9210fa
Compare
In Release Notes also I guess :) |
rock3r
left a comment
There was a problem hiding this comment.
Excellent fix, thanks <3
|
Ready to merge |
Fixed, tnx! |
…nd prevent unintended selection - Update KeyActions to skip selection when `SelectionMode` is set to `None`. - Adjust `SelectableLazyColumn` to avoid auto-selecting items in `None` mode, even on initial focus. - Add test coverage for `SelectionMode.None` to ensure no selection occurs on click or focus. Signed-off-by: Nebojsa.Vuksic <nebojsa.vuksic@jetbrains.com> closes #3446 (cherry picked from commit 9d85107ab1c2d2f66f03000461f9d242ad48d2f0) (cherry picked from commit d0e76589daf5ead3b0a830f0a200726f81a19063) IJ-MR-193916 GitOrigin-RevId: d1181b2a81893bc47f36551f849d8bf5c1be6cfa
…nd prevent unintended selection - Update KeyActions to skip selection when `SelectionMode` is set to `None`. - Adjust `SelectableLazyColumn` to avoid auto-selecting items in `None` mode, even on initial focus. - Add test coverage for `SelectionMode.None` to ensure no selection occurs on click or focus. Signed-off-by: Nebojsa.Vuksic <nebojsa.vuksic@jetbrains.com> closes #3446 (cherry picked from commit 9d85107ab1c2d2f66f03000461f9d242ad48d2f0) (cherry picked from commit da60f5db7177830067aec2dfcb9c547ba20f1e5f) IJ-MR-193915 GitOrigin-RevId: 60e41aa998af7434a5fbd5ba23865550c0359dbb
[JEWEL-1284] Fix SelectableLazyColumn to respect SelectionMode.None and prevent unintended selection
Labels:
jewelProblem
When
SelectionMode.Noneis passed toSelectableLazyColumn, items still get selected in two scenarios:DefaultSelectableLazyColumnEventAction.handlePointerEventPressfalls through to theelsebranch and unconditionally setsselectedKeys/lastActiveItemIndex, ignoring the selection mode entirely.LaunchedEffect(isFocused)inSelectableLazyColumncallsonSelectFirstItemwhenever the list gains focus with no prior selection, without checking whether selection is disabled.The same issue exists in
DefaultTreeViewPointerEventAction, which delegates to the base class without an early return forNone.Before fix:
none-selection-broken.mov
After fix:
none-selection-fixed.mov
Fix
DefaultSelectableLazyColumnEventAction.handlePointerEventPress— added an early return forSelectionMode.Nonein theelsebranch, so plain clicks are no-ops when selection is disabled.DefaultTreeViewPointerEventAction.handlePointerEventPress— added an early return at the top of the method forSelectionMode.None, preventing any pointer-driven selection in tree views as well.SelectableLazyColumn— updated theLaunchedEffect(isFocused)guard to also checkselectionMode == SelectionMode.None, preventing the auto-select-first-item behavior on focus.Testing
Added
SelectableLazyColumnSelectionModeNoneTestwith three tests:clicking an item in None mode does not produce any selection— verifiesselectedKeysstays empty after a click.clicking an item in None mode does not trigger onSelectedIndexesChange— verifies the callback is never invoked.focusing the list in None mode does not auto-select the first item— verifies initial focus doesn't silently select the first item.Release notes
Bug fixes
SelectableLazyColumnselecting items on click and on initial focus even whenSelectionMode.Nonewas set