Skip to content

[JEWEL-1284] Fix SelectableLazyColumn to respect SelectionMode.None and prevent unintended selection#3446

Closed
nebojsa-vuksic wants to merge 1 commit into
JetBrains:masterfrom
nebojsa-vuksic:nebojsa.vuksic/JEWEL-1284-SelectionMode.None-is-not-respected-on-pointer-click-and-focus-auto-selection
Closed

[JEWEL-1284] Fix SelectableLazyColumn to respect SelectionMode.None and prevent unintended selection#3446
nebojsa-vuksic wants to merge 1 commit into
JetBrains:masterfrom
nebojsa-vuksic:nebojsa.vuksic/JEWEL-1284-SelectionMode.None-is-not-respected-on-pointer-click-and-focus-auto-selection

Conversation

@nebojsa-vuksic
Copy link
Copy Markdown
Collaborator

@nebojsa-vuksic nebojsa-vuksic commented Mar 4, 2026

[JEWEL-1284] Fix SelectableLazyColumn to respect SelectionMode.None and prevent unintended selection

Labels: jewel

Problem

When SelectionMode.None is passed to SelectableLazyColumn, items still get selected in two scenarios:

  1. On click: DefaultSelectableLazyColumnEventAction.handlePointerEventPress falls through to the else branch and unconditionally sets selectedKeys/lastActiveItemIndex, ignoring the selection mode entirely.
  2. On initial focus: The LaunchedEffect(isFocused) in SelectableLazyColumn calls onSelectFirstItem whenever 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 for None.

Before fix:

none-selection-broken.mov

After fix:

none-selection-fixed.mov

Fix

  • DefaultSelectableLazyColumnEventAction.handlePointerEventPress — added an early return for SelectionMode.None in the else branch, so plain clicks are no-ops when selection is disabled.
  • DefaultTreeViewPointerEventAction.handlePointerEventPress — added an early return at the top of the method for SelectionMode.None, preventing any pointer-driven selection in tree views as well.
  • SelectableLazyColumn — updated the LaunchedEffect(isFocused) guard to also check selectionMode == SelectionMode.None, preventing the auto-select-first-item behavior on focus.

Testing

Added SelectableLazyColumnSelectionModeNoneTest with three tests:

  • clicking an item in None mode does not produce any selection — verifies selectedKeys stays 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

  • JEWEL-1284 Fixed SelectableLazyColumn selecting items on click and on initial focus even when SelectionMode.None was set

@nebojsa-vuksic nebojsa-vuksic force-pushed the nebojsa.vuksic/JEWEL-1284-SelectionMode.None-is-not-respected-on-pointer-click-and-focus-auto-selection branch 2 times, most recently from 656ba70 to 0a5e48d Compare March 4, 2026 12:08
@daaria-s daaria-s added the Jewel label Mar 5, 2026
@daaria-s
Copy link
Copy Markdown
Collaborator

@nebojsa-vuksic looks like the ticket number is wrong, it is JEWEL-1284 I guess

@nebojsa-vuksic
Copy link
Copy Markdown
Collaborator Author

@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>
@nebojsa-vuksic nebojsa-vuksic force-pushed the nebojsa.vuksic/JEWEL-1284-SelectionMode.None-is-not-respected-on-pointer-click-and-focus-auto-selection branch from 0a5e48d to e9210fa Compare March 10, 2026 11:09
@nebojsa-vuksic nebojsa-vuksic changed the title [JEWEL-1286] Fix SelectableLazyColumn to respect SelectionMode.None and prevent unintended selection [JEWEL-1284] Fix SelectableLazyColumn to respect SelectionMode.None and prevent unintended selection Mar 10, 2026
@daaria-s
Copy link
Copy Markdown
Collaborator

@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 🙏

In Release Notes also I guess :)

Copy link
Copy Markdown
Collaborator

@rock3r rock3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent fix, thanks <3

@rock3r
Copy link
Copy Markdown
Collaborator

rock3r commented Mar 10, 2026

Ready to merge

@nebojsa-vuksic
Copy link
Copy Markdown
Collaborator Author

@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 🙏

In Release Notes also I guess :)

Fixed, tnx!

intellij-monorepo-bot pushed a commit that referenced this pull request Mar 30, 2026
…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
intellij-monorepo-bot pushed a commit that referenced this pull request Mar 30, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants