1

The following filter in my react-admin app leads to the list showing both records with status === "active" and records with status === "inactive". It should show only records with status === "active".

<SelectInput 
  alwaysOn 
  source="status" 
  choices={[
    { id: "lead", name: "Lead" },
    { id: "active", name: "Aktiv" },
    { id: "inactive", name: "Inaktiv" },
  ]} 
/>

It seems like it includes records with status === "inactive" because "inactive" contains the substring "active".

Can I do something about that? Have I misconfigured my DataProvider? I am using react-admin-firebase.

1 Answer 1

1

react-admin-firebase always does fuzzy search when searching for strings:

 const isStringSearch = typeof searchValue === 'string';
  if (isStringSearch) {
    return searchThis
      .toString()
      .toLowerCase()
      .includes(searchValue.toLowerCase());
  }

Source

One solution would be to use numbers for status instead:

<SelectInput 
  alwaysOn 
  source="status" 
  choices={[
    { id: 1, name: "Lead" },
    { id: 2, name: "Aktiv" },
    { id: 3, name: "Inaktiv" },
  ]} 
/>

Another solution is to enable lazy loading to search directly against your firebase.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.