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

[test] Fix console warnings while executing tests with React 18 #16386

Merged
merged 5 commits into from
Jan 29, 2025

Conversation

arminmeh
Copy link
Contributor

@arminmeh arminmeh commented Jan 29, 2025

This fixes the warning on React 18 that is breaking the tests
https://app.circleci.com/pipelines/github/mui/mui-x/79788/workflows/e0f5c399-0631-4b3e-a933-7581381b7d66

It does not need a cherry pick.

Before merge:

  • Make sure React 18 tests are passing

@arminmeh arminmeh added test component: data grid This is the name of the generic UI component, not the React module! labels Jan 29, 2025
@arminmeh arminmeh requested review from LukasTy and a team January 29, 2025 14:21
@arminmeh arminmeh force-pushed the avoid-passing-null-ref branch from 1e2a914 to 7eed2d3 Compare January 29, 2025 14:22
@mui-bot
Copy link

mui-bot commented Jan 29, 2025

Deploy preview: https://deploy-preview-16386--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against bdd5977

@LukasTy
Copy link
Member

LukasTy commented Jan 29, 2025

It looks like there are other components, which need similar changes. 🤔

@arminmeh
Copy link
Contributor Author

arminmeh commented Jan 29, 2025

It didn't work, so I took another approach.
React 18 does not like the type that we pass and asks for a function.
With any reference ends up being required current: PropTypes.any.isRequired and null is not accepted
I have made it slightly more precise (still asking for any element), but it seems that it helps

@arminmeh arminmeh changed the title [test] Do not pass null reference as inputRef prop [test] Fix console warnings while executing tests with React 18 Jan 29, 2025
@@ -18,7 +18,7 @@ export type GridFilterInputValueProps<
applyValue: (value: GridFilterItem) => void;
// Is any because if typed as GridApiRef a dep cycle occurs. Same happens if ApiContext is used.
apiRef: RefObject<Api>;
inputRef?: React.Ref<any>;
inputRef?: React.Ref<HTMLElement | null>;
focusElementRef?: React.Ref<any>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I do the same for focusElementRef?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried it, but it requires a bit more changes than just this type, so I left it as any
if it is not super important, I would leave it for now

@arminmeh arminmeh enabled auto-merge (squash) January 29, 2025 15:52
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Nice. 👍

@arminmeh arminmeh merged commit 4eacfd4 into mui:master Jan 29, 2025
19 of 20 checks passed
@arminmeh arminmeh deleted the avoid-passing-null-ref branch January 30, 2025 07:43
A-s-h-o-k pushed a commit to A-s-h-o-k/mui-x that referenced this pull request Feb 4, 2025
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! test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants