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

Filters: Why does Input value sometimes default to true on string types? #11919

Closed
3 tasks done
erondpowell opened this issue Mar 2, 2022 · 4 comments · Fixed by #12597
Closed
3 tasks done

Filters: Why does Input value sometimes default to true on string types? #11919

erondpowell opened this issue Mar 2, 2022 · 4 comments · Fixed by #12597

Comments

@erondpowell
Copy link
Contributor

Preflight Checklist

Describe the Bug

When filtering radio buttons, if you set the operator to no-value-required operator like null, is not null, empty, is not empty, etc. then switch back to an operator that takes a value, it automatically sets the input value to true, however radio buttons appear to be stored as String type, not Boolean. This happens on the other string type Fields I have tested so far.

This seemed like a weird behavior so I'm adding it into bugs... but there are no console errors, so maybe it is just a silly question! 😄

Why start with -- as default Filter Value then switch to true even in cases where it seems like true can't even be filtered for?

To Reproduce

Screen.Recording.2022-03-02.at.2.20.21.PM.mov

Errors Shown

no.

What version of Directus are you using?

9.5

What version of Node.js are you using?

cloud

What database are you using?

cloud

What browser are you using?

safari

What operating system are you using?

Mac

How are you deploying Directus?

cloud

@azrikahar
Copy link
Contributor

Agree that this is a point for UX improvement 👍


Notes on what's happening here

When we switch to null/nnull/empty/nempty, the value is set to true:

case '_null':
case '_nnull':
case '_empty':
case '_nempty':
update(true);
break;

But since contains/ncontains etc doesn't have a switch case, it defaulted to using the original value which is true but casted into a string:

default:
update(Array.isArray(value) ? value[0] : value);
break;

@erondpowell
Copy link
Contributor Author

Cool. Thanks!

@rijkvanzanten
Copy link
Member

@erondpowell We'll leave this open as an improvement. We should clear the value when you switch operators to/from a type that's incompatible with that value 👍🏻

@rijkvanzanten rijkvanzanten reopened this Mar 3, 2022
@erondpowell
Copy link
Contributor Author

@erondpowell We'll leave this open as an improvement. We should clear the value when you switch operators to/from a type that's incompatible with that value 👍🏻

Got ya, jumped straight from email and didn't read Azzy's first line 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants