Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
From working on #1851086: Replace admin/people with a View, it would be good if you could add an option for exposed forms to 'hide reset button'. This would hide the reset button when no exposed input has been added. I.e. It only appears when there are things to reset.
This could do with some work for sure (and tests), but as a quick POC, something like this.
Comment | File | Size | Author |
---|---|---|---|
#28 | 1960094-28.patch | 3.79 KB | damiankloip |
#28 | interdiff-1960094-28.txt | 1.75 KB | damiankloip |
#22 | frontpage.yml_.txt | 4.85 KB | dawehner |
#18 | 1960094-18.patch | 3.88 KB | damiankloip |
#18 | 1960094-18-interdiff.txt | 1.74 KB | damiankloip |
Comments
Comment #1
damiankloip CreditAttribution: damiankloip commentedI don't need the
!empty($this->options['reset_button_hide'])
in the second part of the conditional.Comment #2
damiankloip CreditAttribution: damiankloip commentedAnd a couple of assertions.
Comment #3
dawehnerI'm wondering whether the user expects a JS behavior for hiding the button?
Maybe a dot at the end of the description?
This needs #states, the same as the rest button label.
What an odd logic...
Comment #4
damiankloip CreditAttribution: damiankloip commentedThanks for the review.
Do you mean you think we should implement this with js?
Rerolled to include your other suggestions.
Yep, views has lots of stuff like that from the ages :)
Comment #5
dawehnerWell, not sure whether this flickering would cause issues, so maybe this could be an option? It feels like we should ask bojhan,
whether such an UI part should be done in javascript as well.
Comment #6
damiankloip CreditAttribution: damiankloip commentedI will try and ask Bojhan today.
Comment #7
tstoecklerJust an innocent question, feel free to ignore: Is there any reason we should make this an option instead of just hardcoding it. It seems showing a Reset button without any filters applied is a very strange edge-case, unless I'm missing something.
Comment #8
tim.plunkettI also wondered why this wasn't just the hardcoded behavior. When would you want that shown?
Comment #9
Dave ReidAgreed with #7 and #8, I would think this would be enabled by default, or hardcoded.
Comment #10
Crell CreditAttribution: Crell commentedIf your filter form is ajax-enabled, having the Reset button appear and disappear could be jarring, and possibly do weird things to your layout if your CSS isn't expecting it.
That said, I agree this is a "do what Bojhan and yoroy tell us to do" moment.
Comment #11
damiankloip CreditAttribution: damiankloip commentedI like the option. I spoke to Bojhan about this briefly yesterday, I will get him to comment in here.
Comment #12
yoroy CreditAttribution: yoroy commentedOnly showing a reset button when there's something to reset, that's just plain good manners no? It should at least be the default.
I'm sure that if we all try really hard we can come up with a use case for wanting to show a reset when there's nothing to reset ("look! if you'd filter something, you will be able to reset it!"). But where would this setting live and is it really worth the extra checkbox in an already complex UI?
*Edit:* tstoeckler: good thinking, excellent question! :-)
Comment #13
Bojhan CreditAttribution: Bojhan commentedI agree with this approach, by default we should hide it. If there is a usecase where you want to expose it by default, then that should be possible programatically but lets not add another checkbox.
Comment #14
damiankloip CreditAttribution: damiankloip commentedok, Bojhan also agrees that we should just make this default behaviour, so let's remove the options and just set the access to FALSE in the form so it's easy to alter etc..
Comment #15
dawehnerWell, it still feels better to
Shouldn't we move this logic into the if (!empty() bit, as it's not needed unless you have a reset button?
Comment #16
damiankloip CreditAttribution: damiankloip commentedYou are totally right, that didn't make any sense. Thanks!
Comment #17
dawehnerAlso that could move into the if.
Comment #18
damiankloip CreditAttribution: damiankloip commentedLet's move it all in there! good plan.
Comment #19
sunComment #20
damiankloip CreditAttribution: damiankloip commentedComment #21
webchickHm. This doesn't appear to be working 100% for me.
Steps:
- Edited the front page view, exposed both filters.
- Checked the "Include reset button" setting under Advanced > Exposed form style > Settings (took me 10 minutes to find that :P)
- Save.
- Go to front page.
- Despite no filters selected / applied, Reset button still appears.
I do confirm that if I click apply, then Reset, the reset button goes away. But each time I go back to the front page with no filters applied, reset button is there until I click it.
Comment #22
dawehnerIs that caused by the problem, that it's in the advanced area?
I tried to do exactly the steps you described, and mhhh the reset button did not appeared :(
Here is the frontpage config i tested with.
Comment #23
damiankloip CreditAttribution: damiankloip commented@webchick, I can't replicate this either I'm afraid :( It seems no one else can either. Is this still doing the same for you?
Comment #24
damiankloip CreditAttribution: damiankloip commentedSetting back to needs review; we can't replicate webchick's issue :( So more people to test would be great.
Comment #25
tim.plunkettI can not reproduce #21 either. The reset button works as expected.
Comment #26
alexpottThe reset_button_hide option no longer exists.
Comment #27
alexpottBTW I couldn't reproduce #21 either.
Comment #28
damiankloip CreditAttribution: damiankloip commentedGood point alex, I remove that from the test and modified the order so that it made more sense now we don't have the option.
Comment #29
dawehnerLoos great.
Comment #30
alexpottCommitted 1f39cc4 and pushed to 8.x. Thanks!