gregnb / gregnb/mui-datatables

customFilterListOptions.update ignores return values

Open
#1,469 1 comment 1 reaction 0 assignees View on GitHub
investigate further
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

customFilterListOptions.update ignores return values. In editors where you receive warnings about reassign to parameters (disable with // eslint-disable-next-line no-param-reassign ), one might be attempted to make a copy of filterList and return the copy, but this won't work.

## Expected Behavior

returning a deep copy of filterList should work.

## Current Behavior
This line of code
https://github.com/gregnb/mui-datatables/blob/a382f3e8e850c7fcdd395f8594a5e0afefcaf905/src/MUIDataTable.js#L1389

assigns to function parameter (unsafe per eslint rules)

When the function exits changes are lost.

Further, line 1403, does not accept changes to filterList if there had been any:
https://github.com/gregnb/mui-datatables/blob/a382f3e8e850c7fcdd395f8594a5e0afefcaf905/src/MUIDataTable.js#L1403

Also, this line of code in the example is meaningless (even though the function works correctly because it assigns directly to array elements by reference)
https://github.com/gregnb/mui-datatables/blob/ae1d49a61ddafd2a83ac445f279a0a67c434e3de/examples/customize-filter/index.js#L132
## Steps to Reproduce (for bugs)

1.
2.
3.
4.

## Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | |
| MUI-datatables | |
| React | |
| browser | |
| etc | |

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/MUIDataTable.js around lines 1389 and 1403, then review examples/customize-filter/index.js around line 132. Trace how customFilterListOptions.update handles filterList and its return value. Done means returned deep-copy changes are preserved and the example no longer contains the meaningless line.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.