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

[DataGrid] Fix resize issue #96

Merged
merged 1 commit into from
Jul 23, 2020
Merged

[DataGrid] Fix resize issue #96

merged 1 commit into from
Jul 23, 2020

Conversation

dtassone
Copy link
Member

No description provided.

@oliviertassinari
Copy link
Member

How do you reproduce the issue?

@dtassone
Copy link
Member Author

How do you reproduce the issue?

Open a story, hide the addons panel => rows are not extended

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Cool, I could reproduce the bug. Here is a test case for it with our test stack:

import * as React from 'react';
import { createClientRender, act } from 'test/utils';
import { XGrid } from "@material-ui/x-grid";
import { expect } from 'chai';

async function sleep(duration) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, duration)
  });
}

describe('<XGrid />', () => {
  const render = createClientRender();

  it('should resize the width of the columns', async () => {
    // jsdom doesn't support layouting
    if (/jsdom/.test(window.navigator.userAgent)) {
      this.skip();
    }

    const App = (props) => {
      const { width = 300 } = props
      return (
        <div style={{ width, height: 300 }}>
          <XGrid
            rows={[
              {
                brand: "Nike",
              },
            ]}
            columns={[
              { field: "id", hide: true },
              { field: "brand", width: 100 },
            ]}
          />
        </div>
      );
    }

    const { container, setProps } = render(<App />);
    let rect;
    rect = container.querySelector('[role="row"][data-rowindex="0"]').getBoundingClientRect();
    expect(rect.width).to.equal(300 - 2);
    setProps({ width: 400 });
    act(() => {
      window.dispatchEvent(new window.Event('resize', {}));
    });
    await sleep(200);
    rect = container.querySelector('[role="row"][data-rowindex="0"]').getBoundingClientRect();
    expect(rect.width).to.equal(400 - 2);
  });
});

It runs in 300ms, but spend 200ms waiting for the size to update.

What about we work on adding it?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 23, 2020

Not seeing the fix work on https://deploy-preview-96--muix-storybook.netlify.app/ is frustrating.

You can play with my setup on oliviertassinari/material-ui@9a3c143

@dtassone
Copy link
Member Author

dtassone commented Jul 23, 2020

Cool, I could reproduce the bug. Here is a test case for it with our test stack:

import * as React from 'react';
import { createClientRender, act } from 'test/utils';
import { XGrid } from "@material-ui/x-grid";
import { expect } from 'chai';

async function sleep(duration) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, duration)
  });
}

describe('<XGrid />', () => {
  const render = createClientRender();

  it('should resize the width of the columns', async () => {
    // jsdom doesn't support layouting
    if (/jsdom/.test(window.navigator.userAgent)) {
      this.skip();
    }

    const App = (props) => {
      const { width = 300 } = props
      return (
        <div style={{ width, height: 300 }}>
          <XGrid
            rows={[
              {
                brand: "Nike",
              },
            ]}
            columns={[
              { field: "id", hide: true },
              { field: "brand", width: 100 },
            ]}
          />
        </div>
      );
    }

    const { container, setProps } = render(<App />);
    let rect;
    rect = container.querySelector('[role="row"][data-rowindex="0"]').getBoundingClientRect();
    expect(rect.width).to.equal(300 - 2);
    setProps({ width: 400 });
    act(() => {
      window.dispatchEvent(new window.Event('resize', {}));
    });
    await sleep(200);
    rect = container.querySelector('[role="row"][data-rowindex="0"]').getBoundingClientRect();
    expect(rect.width).to.equal(400 - 2);
  });
});

It runs in 300ms, but spend 200ms waiting for the size to update.

What about we work on adding it?

We can do in a bit, I'm doing some refactoring now on pagination
Not sure why it doesn't work, I need to investigate again

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 23, 2020

We can do in a bit, I'm doing some refactoring now on pagination
Not sure why it doesn't work, I need to investigate again

I didn't fully understand what you meant.

  • "We can do it in a bit" are you referring to porting the testing stack from the main repository to here and adding the test case I have shared as the first one, then migrating the puppeteer tests that are possible? Sounds like a perfect plan.
  • "Not sure why it doesn't work" are you referring to the sync issue with storybook? The solution is to apply the approach of the main repo [RFC] Use Babel #50.

@dtassone dtassone merged commit 9451137 into master Jul 23, 2020
@dtassone dtassone deleted the fixResize branch July 23, 2020 15:39
@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Jul 26, 2020
@oliviertassinari oliviertassinari changed the title fix resize issue [DataGrid] fix resize issue Jul 26, 2020
@oliviertassinari oliviertassinari changed the title [DataGrid] fix resize issue [DataGrid] Fix resize issue Jul 26, 2020
dtassone added a commit that referenced this pull request Jul 27, 2020
* Release v0.1.62 (#95)

* v0.1.51

* fix demo app build

* v0.1.52

* v0.1.53

* v0.1.54

* v0.1.55

* v0.1.56

* v0.1.57

* v0.1.58

* v0.1.59

* add missing export

* v0.1.60

* v0.1.61

* hot fix for tsconfig conf

* fix mistypes on the package.json

* fix empty space with prettier

* v0.1.62

* fix lerna.json whitespace

* fix resize issue (#96)

* Bump eslint-config-airbnb-typescript from 8.0.2 to 9.0.0 (#112)

* Pagination refactoring (#100)

* implemented server pagination

* rename pagination options, doc, prettier

* fix lint

* Apply suggestions from code review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* change casing value in featureMode and remove apiref check

* added missing dep in useEffect

* fix broken suggestion code

* fix doc comments

* Apply suggestions from code review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* Fix FeatureMode enum and remove useCallback in demo

* fix import order

* added namespace to function call to remove import

* remove useCallback and add react. to mdx code

* add concurrency in server pagination demo

* fix feature mode export

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* [core] Use the classnames helper (#105)

* [core] Batch small changes (#104)

* [docs] Improve the JSDoc (#106)

* rename events and add onHover event (#103)

* rename events and added onHover event

* rename events and added onHover event

* fix onPageChange rename and merge

* Js doc improvements

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* added hover stories

* small fix and cleanup

* revert rename, back to onRowSelected

* refactor hover and click handlers

* refactor cellParams

* prettier

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* v0.1.63

* v0.1.64

* prettier lerna.json due to lerna

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@oliviertassinari oliviertassinari added the component: data grid This is the name of the generic UI component, not the React module! label Jul 27, 2020
dtassone added a commit that referenced this pull request Jul 28, 2020
* Release v0.1.62 (#95)

* v0.1.51

* fix demo app build

* v0.1.52

* v0.1.53

* v0.1.54

* v0.1.55

* v0.1.56

* v0.1.57

* v0.1.58

* v0.1.59

* add missing export

* v0.1.60

* v0.1.61

* hot fix for tsconfig conf

* fix mistypes on the package.json

* fix empty space with prettier

* v0.1.62

* fix lerna.json whitespace

* fix resize issue (#96)

* Bump eslint-config-airbnb-typescript from 8.0.2 to 9.0.0 (#112)

* Pagination refactoring (#100)

* implemented server pagination

* rename pagination options, doc, prettier

* fix lint

* Apply suggestions from code review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* change casing value in featureMode and remove apiref check

* added missing dep in useEffect

* fix broken suggestion code

* fix doc comments

* Apply suggestions from code review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* Fix FeatureMode enum and remove useCallback in demo

* fix import order

* added namespace to function call to remove import

* remove useCallback and add react. to mdx code

* add concurrency in server pagination demo

* fix feature mode export

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* [core] Use the classnames helper (#105)

* [core] Batch small changes (#104)

* [docs] Improve the JSDoc (#106)

* rename events and add onHover event (#103)

* rename events and added onHover event

* rename events and added onHover event

* fix onPageChange rename and merge

* Js doc improvements

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* added hover stories

* small fix and cleanup

* revert rename, back to onRowSelected

* refactor hover and click handlers

* refactor cellParams

* prettier

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* v0.1.63

* v0.1.64

* prettier lerna.json due to lerna

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
dtassone added a commit that referenced this pull request Jul 28, 2020
* Release v0.1.62 (#95)

* v0.1.51

* fix demo app build

* v0.1.52

* v0.1.53

* v0.1.54

* v0.1.55

* v0.1.56

* v0.1.57

* v0.1.58

* v0.1.59

* add missing export

* v0.1.60

* v0.1.61

* hot fix for tsconfig conf

* fix mistypes on the package.json

* fix empty space with prettier

* v0.1.62

* fix lerna.json whitespace

* fix resize issue (#96)

* Bump eslint-config-airbnb-typescript from 8.0.2 to 9.0.0 (#112)

* Pagination refactoring (#100)

* implemented server pagination

* rename pagination options, doc, prettier

* fix lint

* Apply suggestions from code review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* change casing value in featureMode and remove apiref check

* added missing dep in useEffect

* fix broken suggestion code

* fix doc comments

* Apply suggestions from code review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* Fix FeatureMode enum and remove useCallback in demo

* fix import order

* added namespace to function call to remove import

* remove useCallback and add react. to mdx code

* add concurrency in server pagination demo

* fix feature mode export

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* [core] Use the classnames helper (#105)

* [core] Batch small changes (#104)

* [docs] Improve the JSDoc (#106)

* rename events and add onHover event (#103)

* rename events and added onHover event

* rename events and added onHover event

* fix onPageChange rename and merge

* Js doc improvements

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* added hover stories

* small fix and cleanup

* revert rename, back to onRowSelected

* refactor hover and click handlers

* refactor cellParams

* prettier

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* [test] Add yarn deduplicate step (#107)

* [DataGrid] Set default logLevel to warn (#117)

* override default logLevel to warn

* rerun CI

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* [test] Lint JSON (#108)

* Merging release back to master (#120)

* v0.1.51

* fix demo app build

* v0.1.52

* v0.1.53

* v0.1.54

* v0.1.55

* v0.1.56

* v0.1.57

* v0.1.58

* v0.1.59

* add missing export

* v0.1.60

* v0.1.61

* hot fix for tsconfig conf

* fix mistypes on the package.json

* fix empty space with prettier

* v0.1.62

* fix lerna.json whitespace

* v0.1.63

* v0.1.64

* prettier lerna.json due to lerna

* fix cellClassRule type, fix keyboard timeout, small refactoring (#123)

* fix cellClassRule type, fix keyboard timeout, small refactoring

* prettier fix

* add cancel RAF for focus if new event coming

* added keyboard doc (#125)

* added keyboard doc

* Apply suggestions from code review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>

* [DataGrid] Fix selection issue (#126)

* fix selection issue

* fix selection issue test

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants