Closed (fixed)
Project:
Facets
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Mar 2021 at 09:19 UTC
Updated:
2 Apr 2022 at 11:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jibranThis patch goes with the second proposed resolution.
This change might break something but it is worth a try.
I was unable to find the best way to implement the first proposed resolution.
use views argument to form the URLComment #4
jibranThe test fails are because the current path is not set correctly for the test.
Comment #5
mkalkbrennerIt seems like the path that is used in the test requires a login. That might be a bug in the tests that is revealed by the patch.
Comment #6
jibranFixed the test fails but fixing the test also includes #3191091: QueryString url_processor broken(ish) for Ajax Views.
Comment #7
jibranHere are the tests for this issue.
Comment #8
mkalkbrennerI tested the patch locally. It broke a functionality.
It is possible to show a facet block elsewhere on a page which is not the search view. In this case the generated URLs are wrong.
Without the patch it works fine and clicking on a facet entry elsewhere on the page takes you to the the search result view page.
Comment #9
mkalkbrennerMaybe we should add a switch based on this condition. On the other hand I think that both issues targeted by the latest patch are caused by variations of the "master URL". So maybe we should simply check if the current path starts with the master URL. If yes we can use the current path.
Comment #11
mkalkbrennerComment #12
jibranHow about this? I reverted the changes to existing test cases as they check for the case when the facet block is not placed on the search view.
Comment #13
mkalkbrennerI'll manually test it tomorrow.
Comment #14
neclimdulExcited about this being fixed! I've been running the master request for quite a while now without issue so definitely RTBC from me on that part but I'm not immediately able to grok the rest of this so I'll see if i can make some time to review/test as well.
Comment #15
mkalkbrennerI tested the rendering without source manually.
Comment #16
neclimdulI don't know that this is a blocker because I have a stack of patches precariously stacked to make it work but the differences between this and #3191091: QueryString url_processor broken(ish) for Ajax Views (the SearchApiDisplay::getPath changes) seem to break views ajax paths on the site I need this for. The url gets rewritten to the /views/ajax path and refreshes or history browsing end up with json.
I'll finish tracking down what is breaking and report back but wanted to drop a note about the limitation.
Comment #17
mkalkbrenner@neclimdul your patch in #3191091: QueryString url_processor broken(ish) for Ajax Views will not be accepted as it breaks existing features.
You might need to add additional conditions based on this patch here and re-open your issue.
I think we should commit the current patch here as it seems to fix an issue without breaking others.
What do you think?
Comment #18
neclimdulSorry, I wasn't trying to push the other patch just the other patch didn't cause problems and the difference was somehow breaking my test site.
I think I have some details on how it broke now. The crux of the issue seems to be that isRenderedInCurrentRequest assumes the view is a page and only treats it as rendered if it is in the route parameters. If the view is a block, the display path returns null but the surrounding code falls back on the request everything still works fine in the normal page because that's still the right URL.
However in the always terrible edge case of ajax request, the rendering is happening under ViewAjaxController which hacks the current path but the Request path is still
views/ajaxand the fallback ends up building links to send the user to the views ajax controller.This is a problem on this site because they embedding views in paragraphs so content editors can use standard tools for like hero headers around the view but the view needs to have all the normal "I'm a page" functionality because its the main content. I'll keep digging trying to get a better test case then "this super complicated page on a site" but maybe that will give a starting point.
PS. I didn't realize the other patch broke any features since the tests where green. Do you have something I could review as to what it broke?
Comment #19
jibranIf the problem is in
\Drupal\search_api\Display\DisplayInterface::isRenderedInCurrentRequest()then we have to fix it insearch_api.I think we can add a check in
\Drupal\search_api\Plugin\search_api\display\ViewsDisplayBase::isRenderedInCurrentRequest()that if it is an AJAX request then use views param from request else from route. Or we can just use request and ignore route params altogether.I agree a test case would certainly help here. I have one question though, if the block is on some non view page then why it is not executing
\Drupal\search_api\Plugin\search_api\display\ViewsBlock::isRenderedInCurrentRequest()? Is it because the block is used with AJAX-enabled view? I suspect #2769251: Contextual filter don't work with ajax in view might be the root cause.Comment #20
neslee canil pinto#12 worked out for me, thanks @jibran
Comment #21
patrickmichael commented#12 seems to work fine for me. That is with AJAX off.
Comment #22
mistrae commented#12 worked fine for me
Comment #23
karishmaamin commented#12 worked for me as well
Comment #24
t.maquin commented#12 worked for me ! Thanks
Comment #25
igonzalez commented#12 Deactivation of filters is blocked. Don't work for me
Comment #26
mkalkbrennerTest again with 2.0.x and Drupal 9.
Comment #27
mkalkbrennerIt seems that this patch at least improves the situation. I think we should commit it as it is to have a better base for further patches.
Comment #29
mkalkbrennerComment #31
noman_297 commentedI have applied above patch on 8.x-1.8 version but that did not resolve the issue. I am using facets in a view rest export and with contextual filter Like group id and fulltext search, when I search a keyword I get the whole result but when I visit the facet url ie for blogs or events in my case. I got same all result not specific to the facets. My issue https://www.drupal.org/project/facets/issues/3251730 was closed as its a bit duplicate. my facet is like
{
"url":"http://sitename/api/v1/rest-custom-search/10/BIG%20UNDERSTANDING?IIM%20F...",
"values":{
"value":"event",
"count":2
}
}
10 is group id, iim_facet_filter is the facet filter I am applying. But when I visit the above path it's not giving me the event results but instead it gives me the whole result. Kindly someone help me out. Thanks
Comment #32
anybodyPotential follow-up issue / regression: #3259123: ViewsDisplayBase::isRenderedInCurrentRequest() doesn't let the facet link to reset to original URL