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] Warn when scrollToIndexes has invalid arguments #13578

Open
oliviertassinari opened this issue Jun 21, 2024 · 2 comments
Open

[data grid] Warn when scrollToIndexes has invalid arguments #13578

oliviertassinari opened this issue Jun 21, 2024 · 2 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 21, 2024

Steps to reproduce

Steps:

  1. Open https://stackblitz.com/edit/mui-mui-x-87hc2f?file=src%2Fdemo.tsx,package.json
SCR-20240621-lxww
export default function ColumnAutosizingDynamicRowHeight() {
  const apiRef = useGridApiRef();
  const apiRefPro = useGridApiRefPro();

  React.useEffect(() => {
    setTimeout(() => {
      console.log('scrollToIndexes');
      apiRef.current!.scrollToIndexes({
        rowIndex: 300,
      });
      apiRefPro.current!.scrollToIndexes({
        rowIndex: 300,
      });
    }, 1000);
  }, [apiRef, apiRefPro]);

  return (
    <div style={{ height: 400, width: '100%', display: 'flex' }}>
      <div style={{ width: '50%' }}>
        Community
        <DataGrid apiRef={apiRef} rows={rows} columns={columns} />
      </div>
      <div style={{ width: '50%' }}>
        Pro
        <DataGridPro apiRef={apiRefPro} rows={rows} columns={columns} />
      </div>
    </div>
  );
}

Context

It's related to #4744, I saw this in #12242. It's probably a low priority since it works on the Pro and Premium plan. We can delegate this fix to the community.

Your environment

I can reproduce on v6.19.8 and v7.7.0

Search keywords: -

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! status: waiting for maintainer These issues haven't been looked at yet by a maintainer priority: low To delay as much as possible labels Jun 21, 2024
@michelengelen michelengelen added good first issue Great for first contributions. Enable to learn the contribution process. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 21, 2024
@oukunan
Copy link
Contributor

oukunan commented Jun 23, 2024

it looks like the index does not exist on the first page of pagination, indicating that the DataGrid component's pagination is enabled by this override variable. Let's say we attempt to update rowIndex into the first page's range. It will work with scrollToIndexes in this case.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Jun 23, 2024

In my reproduction, we are trying to scroll to an index that isn't in the scroll container, but the grid says nothing about it.

I would expect something in that order: https://codesandbox.io/p/sandbox/auto-row-height-forked-n684rg?file=%2Fsrc%2Findex.js%3A79%2C12
SCR-20240623-lwne

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Jun 23, 2024
@oliviertassinari oliviertassinari changed the title [data grid] scrollToIndexes doesn't work on community plan [data grid] Warn when scrollToIndexes has invalid arguments Jun 23, 2024
@oliviertassinari oliviertassinari removed the priority: low To delay as much as possible label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

No branches or pull requests

3 participants