I am using Drupal 8.4.4 and BEF 8.x-3.0-alpha3
I have created a block view and am using BEF to create a link filter based on a text list field
When I preview the view, the links work with AJAX. If I look at the href of one the the links, I see
http://joyer.localhost/admin/structure/views/view/portfolio/preview/block_1?_wrapper_format=drupal_ajax&field_type_value=SEO
If I place the block view on a page, the links no longer work with AJAX. Instead it requires a page reload. Looking at the href of one of the links, I see
http://joyer.localhost/test-page?field_type_value=SEO
It appears to be an issue only if I select links as when I change the views BEF filter to checkboxes instead of links, AJAX works on the page as expected.
No console errors appear.
Comment | File | Size | Author |
---|---|---|---|
#84 | interdiff_83-84.txt | 5.2 KB | druplr |
#84 | interdiff_80-84.txt | 5.93 KB | druplr |
#84 | better_exposed_filters-2938761-84.patch | 3.32 KB | druplr |
#83 | views.view_.bef_2938761_test_multiple_bef_links.yml | 13.7 KB | druplr |
#83 | interdiff_82-83.txt | 4.76 KB | druplr |
Issue fork better_exposed_filters-2938761
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dimashorokhov CreditAttribution: dimashorokhov commentedYes, I have this problem too. Can somebody help us? Please
Comment #3
danjordan CreditAttribution: danjordan commentedI noticed this issue for BEF Drupal 7 version. https://www.drupal.org/project/better_exposed_filters/issues/1268150
Looking at the final comment, there is a question on whether this fix got rolled into D8 version.
Does any have BEF Links working with AJAX on D8?
Comment #4
wolfhowling CreditAttribution: wolfhowling commentedI have the same problem, only happens with links.
Comment #5
danjordan CreditAttribution: danjordan commentedAs a temporary workaround I am using checkboxes / radio buttons instead of links and using CSS to hide the buttons. Seems to be work OK. Only issue I can see so far I there is no css class to let you know which radio button is active.
Comment #6
wolfhowling CreditAttribution: wolfhowling commented@danjordan you could use the :checked pseudo-class to add indicators to the label.
Comment #7
lamp5I confirmed the same problem on my site. I will try to fix this problem.
Comment #8
Peter van den Heuvel CreditAttribution: Peter van den Heuvel commentedConfirmed, same issue. Used checkboxes instead and styled them as links.
Comment #9
nimoatwoodwaySame Issue. Using D8.5.4 BEF 8.x-3.0-alpha4 with Cores Bartik Theme.
Comment #10
ocastle CreditAttribution: ocastle at Full Bundle commentedYes, i can confirm same issue. +1
Comment #11
alex.87 CreditAttribution: alex.87 as a volunteer commentedSame issue on Drupal core 8.5.6 & Better Exposed Filters 8.x-3.0-alpha4
Comment #12
Yoran Scholiers CreditAttribution: Yoran Scholiers commentedI too have this issue. Core 8.6.1 and Better Exposed Filters 8.x-3.0-alpha4.
Comment #13
RenrhafConfirming this too
Comment #14
bfodeke CreditAttribution: bfodeke at Mediacurrent commentedI am also seeing this same issue but it only shows up when logged in. Works with Ajax for anonymous users which is perplexing
Comment #15
paper boyI have the same issue on Drupal 8.6.3 with BEF Alpha 5. Other than #14 I got it for visitors as well as logged in users.
Comment #16
demonde CreditAttribution: demonde commentedI have the same problem. Ajax not working with BEF Nested Links. Is there any feedback by the maintainer.
Comment #17
paper boyHaven't seen no feedback. But as #5 already mentioned, using checkboxes and styling them accordingly works like a charm. But still Ajax has to be enabled for that form.
Especially if you got multiple exposed filters for one form without Ajax enabled, the approach with the links won't work at all. Clicking a link would always navigate away from your page without taking into account selections in other exposed filters on that form.
Comment #18
demonde CreditAttribution: demonde commentedThanks @paper boy. This works, but it is too much of a workaround. I expect it to cause problems in a live enviroment.
It is unfortunate that there is no answer by the maintainer(s) after almost a year. Just to know what their review is even if it takes another year to fix this.
Comment #19
paper boyWell, it's just some CSS styling and default forms behavior, what problems could that cause?
I've been using something similar on a D7 site for quite a few years without it causing any troubles.
Comment #20
ocastle CreditAttribution: ocastle at Full Bundle commented@demonde, Agreed bit of a work around, but styling checkboxes in this way is common in many scenarios.
I assume we just need to focus on porting the D7 patches into D8. How different is the code base between d7/d8 BEF?
Comment #21
RenrhafSame issue here !
Comment #22
ericdsd CreditAttribution: ericdsd commentedI face the same issue with D8.7 BEF 8x-3.0-alpha6
view's ajax only works if i use radio/checkbox instead of links.
Note that with links it also breaks the ajax pager.
Comment #23
thejimbirch CreditAttribution: thejimbirch at Kanopi Studios commentedThanks to #5, #6, #17. Makes sense that the links wouldn't work with AJAX. Would also be a lot of links for crawlers to follow. I did the checkbox method and it works great. Here are the styles that I ended up going with in case anyone else could benefit from it.
Comment #24
truls1502I can also confirm the issue.
Comment #25
berramou CreditAttribution: berramou commentedI work with BEF with drupal 7 it works great.
But in D8 ajax not working with links.
Comment #26
imclean CreditAttribution: imclean at Digital Ink commentedComment #27
berramou CreditAttribution: berramou commentedThanks @imclean for the update, i already saw the the related issue, for drupal 7, it works for me, but in drupal 8 the issue still.
Comment #28
imclean CreditAttribution: imclean at Digital Ink commentedAdding a related issue properly links the 2 issues. Anyone who comes to this issue can easily see the Drupal 7 issue and potentially have a go at porting the code over. Feel free to have a go if you like.
Comment #29
viswanathsai CreditAttribution: viswanathsai commentedAny Update or Patch on this issue ??
Comment #30
Etroid CreditAttribution: Etroid commentedLooks like someone could take a stab at porting the patch for D7 to D8. Active development is happening on the 8.x-4.x dev branch so please consider applying the patch there. Looks like the work will be two-fold:
- Add hidden select element to exposed form with all link values (used for store form submission values
- Attach javascript to page when bef_links are used.
- Prevents click on link element and select matching hidden value
D7 patch in question: https://www.drupal.org/files/issues/ajax_doesnt_work_with-1268150-132.patch
Comment #31
hockey2112 CreditAttribution: hockey2112 commented@thejimbirch, thanks for the CSS. I can't get the checked styling to work though... any tips? Can you maybe provide a link to the site where you used this CSS so I can take a look and attempt to troubleshoot/replicate on my website?
Comment #32
imre.horjanHere's a patch.
In my solution URL is now generated quite similar as in the Views Infinite Scroll module (keeping only the query part of the URL, like "?field_type_value=SEO").
I also removed "_wrapper_format=drupal_ajax" form URLs, in order not to land on an AJAX result page.
This way BEF will work if used in a views block, and even if loaded by an AJAX request (for example you already used an AJAX pager).
Let me mention that my solution doesn't actually use AJAX for reloading the view. A full page reload is done.
I appreciate if you can review and test it.
Comment #33
imre.horjanComment #34
dshields CreditAttribution: dshields commentedNot to be rude, but because the "solution doesn't actually use AJAX for reloading the view. A full page reload is done,", I'm setting this back to "Needs work".
Comment #35
Piratawww CreditAttribution: Piratawww commentedI still have the same problem with the last dev release. #32 dont help with ajax link problems
Comment #36
imre.horjanHiding my patch...
As I remember we changed links to checkboxes and it works.
Comment #37
OleksiyCould be related to #3146471: BEF overrides the currently active request object
Comment #38
playful CreditAttribution: playful commentedThis continues to be an issue in BEF 8.x-4.0-beta1. Using Drupal 8.8.6. Worked fine in Drupal 7... any update on this?
Comment #39
Nigel CunninghamIn my case, I've found that the issue is simply that I'm using Select 2 as well, and the auto submission works if I add a little delay for Select2 to update the selection before it clicks the button for me. Attaching a patch that does this.
Comment #40
Nigel CunninghamComment #41
Neslee Canil PintoPatch no longer applies
Comment #42
KapilV CreditAttribution: KapilV as a volunteer and at OpenSense Labs commentedComment #43
KapilV CreditAttribution: KapilV as a volunteer and at OpenSense Labs commentedComment #44
Neslee Canil Pinto@kapilkumar0324 why did you assigned and then unassigned yourself?
Does that mean you are creating a patch for this issue?
Comment #45
anushrikumari CreditAttribution: anushrikumari at OpenSense Labs commentedComment #46
anushrikumari CreditAttribution: anushrikumari at OpenSense Labs commentedSorry, Ignore this patch as I uploaded the wrong one.
Comment #48
Radelson CreditAttribution: Radelson at WebstanZ commentedComment #49
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedReroll the patch for
8.x-5.x
. Please review.Comment #52
Radelson CreditAttribution: Radelson at WebstanZ commentedI've created a merge request following #30 recommendations.
I don't think #49 and #39 are addressing the problem described in the issue summary.
The merge request is trying to fix the original issue : the Links plugin triggers a full page reload even though the views is configured to use AJAX.
Maybe another issue should be created to address #39. It seems related to the auto submit behavior when using Select2 but not related to AJAX using links.
Comment #53
gulshk CreditAttribution: gulshk commentedWhen are you going to merge?
Comment #54
Tom GrootjansI've created a patch for the changes made in the merge request mentioned in #52
Comment #55
Radelson CreditAttribution: Radelson at WebstanZ commentedSetting as needs review, it seems to work well enough for us and it's in use elsewhere.
Comment #56
igonzalez CreditAttribution: igonzalez commented#54 works for me
Comment #57
monya CreditAttribution: monya as a volunteer and commentedHere's a small fix for the case with two or more bef links on the page.
Comment #58
Volker23 CreditAttribution: Volker23 as a volunteer commentedtesting #54 and #57 neither patch works for me. Drupal 9.1.4 BEF 8.x-5.0-beta1
Comment #59
camslice CreditAttribution: camslice commentedI'm getting the same testing patches #54 and #57. Neither seem to work on Drupal 9.1.5 BEF 8.x-5.0-beta1
Comment #60
Radelson CreditAttribution: Radelson at WebstanZ commentedSetting this as needs work as it doesn't seem to work for some people.
The patch is still in use for us but we will maybe run into problems when we update to 9.x.
Comment #61
mudassar774 CreditAttribution: mudassar774 commentedIt don't works with d9
Comment #62
savage1974 CreditAttribution: savage1974 commentedIt works with drupal 9.18. but with some nuances (view - page's display) - see attached pic.
Comment #63
cedeweyPatch #57 works for me on Drupal 8.9.16
Comment #64
nortmas CreditAttribution: nortmas commentedGood job guys! But I guess there is still a small issue. After I clicked a link, I can't unclick it to reset the results, which is a problem from my point of view.
Comment #65
nortmas CreditAttribution: nortmas commentedHere is the patch, which fixes the issue mentioned in comment #64
Comment #66
Fabsgugu CreditAttribution: Fabsgugu at Gaya commentedPatch #65 works for me on Drupal 9.1.10
Comment #67
Hydra CreditAttribution: Hydra as a volunteer and at erdfisch commentedJust tested this patch while researching - the patch works, but only for one exposed filter using links option at once. It will break when using multiple filters at once.
Another option would be to go with the radio/checkbox solution build in and use heavy css to make them look like links.
Comment #68
camslice CreditAttribution: camslice commentedUnfortunately patch #65 doesn't work for me. Page reloads every time.
Comment #69
cedeweyThe page is still refreshing for me as well when a link filter is clicked on a Views block using AJAX.
Comment #70
fskreuz CreditAttribution: fskreuz commentedThe patch from #65 somewhat works with a few caveats:
- What the patch does is hide the select and add another form element for the links. This causes administration to be weird because you're really still administering the select, not the set of links. The links appear at the end of the filters. This also makes filter order and modules like VEFL go weird.
- The patch doesn't work when you pull out the exposed form as a block, page will still refresh. That's because
viewExecutable->preExecute()
is never called to update the view's AJAX capabilities from the display handler. MeaningviewExecutable->ajaxEnabled()
will always returnfalse
. This check should instead beif($this->view->display_handler->ajaxEnabled())
to grab the AJAX capability directly from the associated display.Tried a few things but didn't work out. Sticking with the "hide the checkboxes and style labels as buttons" approach for now.
Comment #71
joseph.olstadthere looks to be a much simpler (better?) patch here: #3232628: Better Exposed Filter AJAX not working with Datepicker
Comment #72
cedeweyI tested https://www.drupal.org/project/better_exposed_filters/issues/3232628 and it did not resolve the filter link behavior for me. In my case the site is on Drupal 8.9.19
Comment #73
Krzysztof DomańskiDeactivate the current link.
Comment #74
rokzabukovec CreditAttribution: rokzabukovec at Agiledrop - Your Trusted Drupal Teammates commentedI used this patch to getting the exposed filters in view blocks work. Please review.
Comment #75
cedewey@Krzysztof Domański your patch worked for my use case. Thank you!
Comment #76
furamag CreditAttribution: furamag as a volunteer commentedPatch #73 works for me. Thank you!
Comment #77
joseph.olstad#3175500-10: Exposed filter with the operator "between" not collapsed if this option is enabled
Comment #78
joseph.olstadComment #79
ysamoylenko CreditAttribution: ysamoylenko at EPAM Systems commentedHello everyone.
I've tested patch #73 and it works fine with one additional fix mentioned by @fskreuz in #70.
I've added an additional check for display handler ajax status if default view ajax status could not be resolved.
For my particular case, it works.
Please review the patch and interdiff.
Comment #80
ysamoylenko CreditAttribution: ysamoylenko at EPAM Systems commentedPlease ignore #79 and use #80 as I accidentally removed JS fixes from #73 in #79.
Sorry for that.
Please review #80 instead.
Comment #81
ipinchuk CreditAttribution: ipinchuk at EPAM Systems commentedHi there,
Patch #80 has been checked. It works fine.
Thanks for your contribution
Comment #82
ocastle CreditAttribution: ocastle at Full Bundle commentedI've just tried this patch on a new project.
There is an issue when the exposed form is used in a block.
Due to the change in the html structure the form submit isn't submitted.
$wrapper.closest('form').find('.form-submit').click();
Closest form isn't found as the wrapper element surrounds the form element rather than the form containing the wrapper.
Attaching patch to solve this.
Comment #83
druplr CreditAttribution: druplr commentedThis patch adds support for multiple BEF links fields. For an example, you can try the test view attached below, place the exposed filter block, and add some test content (published/unpublished, sticky/unsticky, promoted/unpromoted).
Also, instead of deactivating the currently selected BEF link, the new patch follows the original behaviour of the module: re-selecting the selected BEF link, deselects it now.
Comment #84
druplr CreditAttribution: druplr commentedMy previous patch (#83) when combined with "#2901927: Preserve links filter value when submitting Views exposed form" and AJAX enabled results in two form elements for every BEF link filter:
As a result, the query string becomes unnecessarily long.
So I tried to include the patch from "#2901927: Preserve links filter value when submitting Views exposed form" to patch #83. After some adjustments, the new patch turned out to be leaner and simpler.
This new patch supports:
Comment #85
druplr CreditAttribution: druplr commentedComment #86
leanderjccHi,
the patch at #84 fixed the issue for me with version 5.0.0. Very nice work! Test returned green so marking this RTBC.
Comment #87
whitewebs CreditAttribution: whitewebs at Investis Digital commentedHello!
I experienced this issue on one of our sites and it was tricky to spot what was at fault. Great to see this has been flagged as an issue and has been worked on. I have reviewed the patch at #84 and can confirm it works nicely!
Thank you kindly.
Simon
Comment #89
rlhawkThis looks good and is committed. Thanks to all who contributed to the solution.
Comment #90
Neslee Canil PintoWe also need to apply, test, and commit these changes for 8.x-4.x branch.
Comment #92
Neslee Canil PintoAdded the changes to 8.x-4.x branch, made manual reroll for the branch.