Skip to content

[tree view][SimpleTreeView] onSelectedItemsChange called with arrays in single-select mode #22246

@joshkel

Description

@joshkel

Steps to reproduce

Steps:

  1. Open this link to live example: https://codesandbox.io/p/sandbox/elastic-andras-7l3hgt
  2. Open the CodeSandbox console.
  3. Click one of the top-level options (e.g., 'Grid').

Current behavior

handleSelectedItemsChange is fired twice, once with an id parameter of 'grid' and once with an id parameter of ['grid'].

Expected behavior

handleSelectedItemsChange is only fired once. It's only fired with a scalar id parameter, since multiSelect is false.

Context

This behavior appears to be new in 9.x.

Your environment

npx @mui/envinfo

  System:
    OS: macOS 26.4.1
  Binaries:
    Node: 24.14.0 - /Users/josh/.nvm/versions/node/v24.14.0/bin/node
    npm: 11.9.0 - /Users/josh/.nvm/versions/node/v24.14.0/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 147.0.7727.103
    Edge: 147.0.3912.86
    Firefox: 149.0.2
    Safari: 26.4
  npmPackages:
    @base-ui/utils:  0.2.8 
    @emotion/react:  11.14.0 
    @emotion/styled:  11.14.1 
    @mui/core-downloads-tracker:  9.0.0 
    @mui/icons-material:  9.0.0 
    @mui/lab:  9.0.0-beta.2 
    @mui/material:  9.0.0 
    @mui/private-theming:  9.0.0 
    @mui/styled-engine:  9.0.0 
    @mui/system:  9.0.0 
    @mui/types:  9.0.0 
    @mui/utils:  9.0.0 
    @mui/x-date-pickers:  9.0.2 
    @mui/x-internals:  9.0.0 
    @mui/x-tree-view:  9.0.2 
    @types/react: ^18.3.27 => 18.3.27 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^6.0.3 => 6.0.3 

Search keywords: onSelectedItemsChange

Metadata

Metadata

Assignees

Labels

scope: tree viewChanges related to the tree view. This includes TreeView, TreeItem.type: bugIt doesn't behave as expected.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions