Skip to content
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

[data grid] Did the behavior of onRowSelectionModelChange change in version 7.21.0? #15097

Closed
mschaefer-gresham opened this issue Oct 24, 2024 · 2 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ support: question Community support but can be turned into an improvement

Comments

@mschaefer-gresham
Copy link

mschaefer-gresham commented Oct 24, 2024

The problem in depth

When using version 7.21.0, clicking on a row fires onRowSelectionModelChange multiple times. Calls after the first call are passed an empty row selection.

When using version 7.20.0 and earlier the behavior is correct - onRowSelectionModelChange is only called once and is passed the correct row selection.

Why did the behavior change?

Using the follow component to test.

import React, { useState, useCallback, type JSX } from 'react';
import {
    DataGridPremium,
    type GridColDef, type GridRowModel,
    type GridRowSelectionModel,
} from '@mui/x-data-grid-premium';

const rows: GridRowModel[] = [
    { id: 'row.1', value1: 'Sam' },
    { id: 'row.2', value1: 'Harry' },
    { id: 'row.3', value1: 'Frank' },
];

const columns: GridColDef[] = [
    { headerName: 'Column 1', type: 'string', width: 100, field: 'value1' },
    { headerName: 'Column 2', type: 'string', width: 100, field: 'value2' },
    { headerName: 'Column 3', type: 'string', width: 100, field: 'value3' },
    { headerName: 'Column 4', type: 'string', width: 100, field: 'value4' },
    { headerName: 'Column 5', type: 'string', width: 100, field: 'value5' },
];

const ScrapGridPremium = (): JSX.Element => {

    const [rowSelectionModel, setRowSelectionModel] =
        useState<GridRowSelectionModel>([]);

    const onSelectionModelChange = useCallback(
        (newSelectionModel: GridRowSelectionModel) => {
            console.log('onRowSelectionModelChange:', newSelectionModel);
            setRowSelectionModel(newSelectionModel);
        },[setRowSelectionModel],
    );

    return (
        <div style={{ height: 400, width: '100%' }}>
            <DataGridPremium
                columns={columns}
                rows={rows}
                rowSelectionModel={rowSelectionModel}
                onRowSelectionModelChange={onSelectionModelChange}/>
        </div>
    );
};

export default ScrapGridPremium;

Your environment

`npx @mui/envinfo`
    System:
    OS: macOS 14.7
    CPU: (14) arm64 Apple M3 Max
    Memory: 72.34 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.13.1 - ~/.nvm/versions/node/v20.13.1/bin/node
    Yarn: 4.5.0 - ~/.nvm/versions/node/v20.13.1/bin/yarn
    npm: 10.5.2 - ~/.nvm/versions/node/v20.13.1/bin/npm
  Managers:
    Homebrew: 4.3.23 - /opt/homebrew/bin/brew
    pip3: 21.2.4 - /usr/bin/pip3
    RubyGems: 3.0.3.1 - /usr/bin/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 16.0.0 - /usr/bin/gcc
    Git: 2.39.5 - /usr/bin/git
    Clang: 16.0.0 - /usr/bin/clang
    Subversion: 1.14.3 - /opt/homebrew/bin/svn
    Curl: 8.7.1 - /usr/bin/curl
    OpenSSL: 3.3.2 - /opt/homebrew/bin/openssl
  Servers:
    Apache: 2.4.59 - /usr/sbin/apachectl
  Virtualization:
    Docker: 27.2.0 - /usr/local/bin/docker
    Parallels: 20.1.0 - /usr/local/bin/prlctl
  IDEs:
    VSCode: 1.94.2 - /usr/local/bin/code
    Vim: 9.0 - /usr/bin/vim
    WebStorm: 2024.2.3
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Perl: 5.34.1 - /usr/bin/perl
    Python3: 3.9.6 - /usr/bin/python3
    Ruby: 2.6.10 - /usr/bin/ruby
  Databases:
    SQLite: 3.43.2 - /usr/bin/sqlite3
  Browsers:
    Edge: 130.0.2849.46
    Safari: 18.0.1

Search keywords: grid, onSelectionModelChange
Order ID: 45466

@mschaefer-gresham mschaefer-gresham added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Oct 24, 2024
@github-actions github-actions bot added component: data grid This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Oct 24, 2024
@mschaefer-gresham mschaefer-gresham changed the title [question] Did the behavior of onSelectionModelChange change in version 7.21.0? [question] Did the behavior of onRowSelectionModelChange change in version 7.21.0? Oct 24, 2024
@KenanYusuf KenanYusuf changed the title [question] Did the behavior of onRowSelectionModelChange change in version 7.21.0? [data grid] Did the behavior of onRowSelectionModelChange change in version 7.21.0? Oct 24, 2024
@KenanYusuf KenanYusuf added the support: question Community support but can be turned into an improvement label Oct 24, 2024
@KenanYusuf
Copy link
Member

KenanYusuf commented Oct 24, 2024

Hi @mschaefer-gresham thanks for raising the issue - we have another issue describing the same behaviour so I will close this and continue the discussion there.

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@mschaefer-gresham How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants