I've been using an event handler to run a script that filters table data. It was working one day and not working the next. I have checked my table name, column names and table data and I don't see any issues.
Hey @yourbudweiser, can confirm this weird behavior. Using setFilterStack has been consistent, so glad you have a working solution for now. I've filed a bug report for setFilter and can update here as I get any information on the status.
@yourbudweiser Just to further update, looks like this is a mostly an issue of timing with async methods affecting the filterStack.
The reason that setFilterStack is currently working for you is because it updates the entire filterStack regardless of what is currently there. So if clearFilterStack doesn't complete in time, the filter is still updated accordingly.
setFilter is designed to update the current filterStack, so it's state before the method is called is important, and in this case that state is inconsistent.
We are releasing a fix for this next week, where the filterStack methods can be awaited. So your previous code should work with some slight modification:
Simple example: I want to clear the filterStack of a table. Assumption: after await table1.clearFilterStack() the filterStack will be null. But its not directly. Eventually it is null when I check it a second time.
Ah got it. I think this is actually a symptom of something else entirely. By default, JS queries close over the value of certain variables while executing, meaning the references themselves can become stale. There's a way to override this behavior in the "Advanced" settings menu.
oh wow, thanks! But this is VERY well hidden on not intuitive. Why would I ever NOT want to keep references in my queries in sync with the app? Also the first time I am actually aware that there is a setting like this. Tbh: I think this would have saved me from a lot of debugging and finding workarounds for strange behaviour.
It's actually pretty rare for a single query to both mutate and read the value of external variables! On top of that, maintaining those variable references can be expensive. That said, I agree that the toggle could be more visible!