https://avo.cool logo
Basic Select Filters I got two issues with the...
# resources
w
Basic Select Filters I got two issues with the basic select filters. First one is just a documentation issue - on [this page](https://docs.avohq.io/4.0/basic-filters.html#show-a-message-when-there-are-no-options), it states that
self.empty_message
is shown when there are no options. But actually, it is simply used in the template as
include_blank: filter.class.empty_message || "—"
. So it can be used to overwrite the default unselected value with e.g. "All" or to remove the empty option all together. Might be even easier to just call this
self.include_blank
😅 The other one is also about the empty option. When e.g. browsing the [Avo demo posts resource](https://main.avodemo.com/avo/resources/posts), there is a basic select filter for the published state. Selecting published posts works, and then switching back to "–" shows all posts again. However, switching on persistence with
config.persistence = { driver: :session }
in the
avo.rb
breaks this behaviour. Now switching back to "–" will always switch back to the last chosen option (e.g. published). When adding a
debugger
to the
def apply
for this filter, it shows that the value only ever comes in as "published", but never as empty string, nil, or similar, so this happens before this method. I didn't look into the code here, but probably it just checks if an option is selected and if not, applies the last filter state from the persistent memory. So this probably needs some kind of check whether the empty option was picked on purpose or if it is the initial page visit for that resource...
m
Thread automatically created by Tim in #1141725701549072486
w
(Note that I didn't check this behaviour with the avo demo, but only with my project locally - but it was pretty clear, just switching on or off the persistence and restarting the rails server broke or fixed the behaviour)
l