-
-
Notifications
You must be signed in to change notification settings - Fork 540
5103 catch bad date ranges #5120
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
Conversation
Hmmm.. The behaviour of the date range widget is definitely a little off, but it looks like it already was. Sometimes if you change the content of the date range to something that is not valid it 'silently' reverts back to what it was before, and sometimes it triggers the error and reverts to the default. What we have here will prevent the 500 error, which is the desired outcome. In an ideal world, we'd get feedback and a consistent result (either the default or reverting to what was before) in all these cases. @wjwb-uk -- are you interested in digging deeper on this pull request, and making the whole thing work consistently with feedback, etc? That might be a bit of scope creep. If not, would it be easy to have it revert to what was there before instead of the default? |
@cielf Happy to dig a little deeper tonight. I hadn't noticed the silent reverts to old values, my gut is telling me it's something to do with the client side date picker. To revert to the previous value after an invalid input, we’d need to store the last valid range somewhere, I'm thinking either in the session or passed along with the form as a hidden input. I feel like the hidden input is probably the cleaner solution here, since it keeps things stateless and works well with existing param based filtering. I’ll take a closer look and see if I can make the behavior more consistent with that approach if that sounds good to you? |
I'm not the last word on technical approaches - but from a functional pov, I don't think it really matters whether we revert to a default or to what was there (will be the same in most cases), as long as we're consistent. |
Merging main back in as I've been on vacation for a few weeks will revisit this week :) |
@cielf No sweat, these things happen. Will close merge request and pickup another issue :) |
Resolves #5103
Description
Improves the handling of invalid
date_range
parameters in the Purchases page and other index pages that use the date range filter.With this change:
flash.now[:error]
message is shown to inform the user that the input was invalid and the default was used instead.Alternatives considered:
Type of change
How Has This Been Tested?
Screenshots