Skip to content

[DataGrid] Fix memoized selectors with arguments#15215

Merged
MBilalShafi merged 12 commits intomui:masterfrom
MBilalShafi:fix-memoized-argument-selectors
Nov 8, 2024
Merged

[DataGrid] Fix memoized selectors with arguments#15215
MBilalShafi merged 12 commits intomui:masterfrom
MBilalShafi:fix-memoized-argument-selectors

Conversation

@MBilalShafi
Copy link
Member

As reported by @kenanyusuf, memoized selectors with arguments weren't working properly, this PR aims to fix that.

Extracted from #15200 to separate from the BC.

@MBilalShafi MBilalShafi added internal Behind-the-scenes enhancement. Formerly called “core”. scope: data grid Changes related to the data grid. labels Oct 31, 2024
@mui-bot
Copy link

mui-bot commented Oct 31, 2024

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

Generated by 🚫 dangerJS against d9d446d

@MBilalShafi MBilalShafi added needs cherry-pick The PR should be cherry-picked to master after merge. type: bug It doesn't behave as expected. labels Oct 31, 2024
@MBilalShafi MBilalShafi marked this pull request as ready for review October 31, 2024 10:57
@MBilalShafi MBilalShafi requested review from a team and romgrk October 31, 2024 10:58
Copy link
Member

@kenanyusuf kenanyusuf left a comment

Choose a reason for hiding this comment

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

Tested on my working branch using memoized v8 selectors and it is working as expected 👍

Copy link
Member

@kenanyusuf kenanyusuf left a comment

Choose a reason for hiding this comment

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

@MBilalShafi Spotted an issue with the types for selectors created using createSelectorMemoizedV8:

When calling the selector directly, it seems to require an args arg even if additional args are not used by the selector.

Screenshot 2024-10-31 at 14 54 39

Selector:

export const gridColumnDefinitionsSelectorV8 = createSelectorMemoizedV8(
  gridColumnFieldsSelectorV8,
  gridColumnLookupSelectorV8,
  (allFields, lookup) => allFields.map((field) => lookup[field]),
);

(ignore all the selectors being suffixed with v8, it's for testing purposes)

@MBilalShafi MBilalShafi requested review from kenanyusuf and romgrk and removed request for romgrk November 1, 2024 13:45
Copy link
Member

@kenanyusuf kenanyusuf left a comment

Choose a reason for hiding this comment

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

Not sure what's going on with Argos 🤔 but the changes LGTM.

@MBilalShafi
Copy link
Member Author

MBilalShafi commented Nov 7, 2024

Not sure what's going on with Argos 🤔 but the changes LGTM.

Yep this is a flaky one, I didn't dig deep yet though it seems to be somehow related to #14130

Comment on lines +151 to +154
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true, argsIgnorePattern: '^_' },
],
Copy link
Member Author

@MBilalShafi MBilalShafi Nov 7, 2024

Choose a reason for hiding this comment

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

This change extends the eslint-config-airbnb-typescript's rule previously in action by adding an argsIgnorePattern for allowing _ based unused variables ignored by eslint parser.

It might be useful to add it to the core .eslintrc.js and extend from there.

CC @mui/x @mui/code-infra

Copy link
Member

Choose a reason for hiding this comment

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

👍 feel free to open a PR to add this to the Core config.

@MBilalShafi MBilalShafi enabled auto-merge (squash) November 8, 2024 10:00
@MBilalShafi MBilalShafi merged commit 1b6c93d into mui:master Nov 8, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2024

Cherry-pick PRs will be created targeting branches: v7.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Behind-the-scenes enhancement. Formerly called “core”. needs cherry-pick The PR should be cherry-picked to master after merge. scope: data grid Changes related to the data grid. type: bug It doesn't behave as expected. v7.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants