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] Improve sizing logic #350

Merged
merged 9 commits into from
Oct 1, 2020

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Sep 25, 2020

Closes #344. I have refactored AutoSizer from classes to hooks for free. It was interesting to dive into the logic and fix the integration with the grid (of course I have made mistakes during the migration that took me almost an hour to identify).

@oliviertassinari oliviertassinari force-pushed the fix-autosize-issue branch 2 times, most recently from d97fb30 to 060eeae Compare September 25, 2020 23:06
@oliviertassinari oliviertassinari marked this pull request as ready for review September 25, 2020 23:06
@@ -161,7 +172,7 @@ export const GridComponent = React.forwardRef<HTMLDivElement, GridComponentProps
);

return (
<AutoSizerWrapper onResize={debouncedOnResize} style={{ height: 'unset', width: 'unset' }}>
Copy link
Member Author

Choose a reason for hiding this comment

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

The fix is to remove style={{ height: 'unset', width: 'unset' }}

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Sep 28, 2020
(appender as any)[method](`[${name}] - ${message}`, ...rest);

// Don't console log non errors in production
if (appender === console && method !== 'error' && process.env.NODE_ENV === 'production') {
Copy link
Member

Choose a reason for hiding this comment

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

that's not necessary, we use the factory to initialize the logger and we want to log errors in prod as well

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that it's important for 1. of #350 (comment).
If the message should be logged in production, then it should be an error, not a warning. I forgot to add forceDebug

Suggested change
if (appender === console && method !== 'error' && process.env.NODE_ENV === 'production') {
if (
appender === console &&
!forceDebug &&
method !== 'error' &&
process.env.NODE_ENV === 'production'
) {

Copy link
Member

Choose a reason for hiding this comment

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

IMHO the logging level should not change between prod and dev. Otherwise ppl will have an error in prod and not in dev and they will be like WTF

Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise ppl will have an error in prod and not in dev and they will be like WTF

This can't happen in the current configuration. All the errors reported in production as also reported in development. Warn in dev, error only in prod is how React and Material-UI behaves (and have been since the beginning), developers are used to it. I think that the surprise will be if we report warnings in prod.

IMHO the logging level should not change between prod and dev.

Oh, I didn't think about that. It could be cleaner. We could have the log level as a warning in dev and error in production, instead of the custom forking logic. This sounds better and more consistent! I can do that. Thanks for the idea :)

dtassone pushed a commit to dtassone/material-ui-x that referenced this pull request Nov 9, 2020
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.

[DataGrid] Height increase in an endless loop
2 participants