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 filter of type Radio doesn't filter properly #5742

Closed
1 task
marinamas opened this issue Jul 29, 2024 · 3 comments · Fixed by #5877
Closed
1 task

DataGrid filter of type Radio doesn't filter properly #5742

marinamas opened this issue Jul 29, 2024 · 3 comments · Fixed by #5877
Assignees
Labels
component: Datagrid Sev 3 Visible or noticeable to users but does not impede functionality. Has a workaround. type: bug 🐛 Something isn't working

Comments

@marinamas
Copy link

marinamas commented Jul 29, 2024

Package

Carbon for IBM Products

Description

  1. Create a Datagrid table with filters
  2. Add a radio filter to the table
  3. When filtering string it is not looking for the exact string match
    For ex : incase two filter values are active and inactive. , using inactive as filter will return rows having active values as well. This happens with filter of type radio and dropdown
    (The checkbox filter works as expected)

Attached a video for reference

Screen.Recording.2024-07-29.at.11.16.40.AM.mov

Component(s) impacted

DataGrid filter of type radio

Browser

No response

@carbon/ibm-products (previously @carbon/ibm-cloud-cognitive) version

"@carbon/ibm-products": "2.45.0",

Suggested Severity

Sev-2

Product/offering

NA

CodeSandbox or Stackblitz example

https://codesandbox.io/p/sandbox/datagrid-clear-fliter-issue-forked-plpt64?file=%2Fsrc%2FExample.js%3A70%2C13

Steps to reproduce the issue (if applicable)

No response

Release date (if applicable)

No response

Code of Conduct

Tasks

Preview Give feedback
@github-project-automation github-project-automation bot moved this to Needs triage 🧐 in Carbon for IBM Products Jul 29, 2024
@matthewgallo matthewgallo added component: Datagrid Sev 3 Visible or noticeable to users but does not impede functionality. Has a workaround. type: bug 🐛 Something isn't working and removed status: needs triage 🕵️‍♀️ labels Aug 5, 2024
@matthewgallo matthewgallo moved this from Needs triage 🧐 to Backlog 🌋 in Carbon for IBM Products Aug 5, 2024
@AlexanderMelox
Copy link
Contributor

AlexanderMelox commented Aug 5, 2024

Found out react-table v7 uses includes() under the hood which the radio button uses since the default is always text unless overidden.
https://github.com/TanStack/table/blob/06703a56890122cedf1b2fa4b82982999537774e/src/filterTypes.js#L1

export const text = (rows, ids, filterValue) => {
  rows = rows.filter(row => {
    return ids.some(id => {
      const rowValue = row.values[id]
      return String(rowValue)
        .toLowerCase()
        .includes(String(filterValue).toLowerCase())
    })
  })
  return rows
}

We might be able to utilize their exactText filter for radios

export const exactText = (rows, ids, filterValue) => {
  return rows.filter(row => {
    return ids.some(id => {
      const rowValue = row.values[id]
      return rowValue !== undefined
        ? String(rowValue).toLowerCase() === String(filterValue).toLowerCase()
        : true
    })
  })
}

@matthewgallo
Copy link
Member

Agreed, exactText looks like what we want here

@marinamas
Copy link
Author

Yes exactText would be perfect.
I have observed the similar behavior with the dropdown filter which doesn't match the exact string.

Checkbox filter is using the exactText

@AlexanderMelox AlexanderMelox moved this from Backlog 🌋 to Needs review 👋 in Carbon for IBM Products Aug 15, 2024
@github-project-automation github-project-automation bot moved this from Needs review 👋 to Done 🚀 in Carbon for IBM Products Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Datagrid Sev 3 Visible or noticeable to users but does not impede functionality. Has a workaround. type: bug 🐛 Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants