-
Notifications
You must be signed in to change notification settings - Fork 96
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
SearchForm's autoload and cause lots of XHR requests #700
Comments
The file search doesn't do that, because the search component isn't actually rendered until you click the search toggle. The GridField and SiteTree search always render their search components, but hide them with CSS. A simple fix could be to do the same thing as the File Search. A side effect of this is that if you untoggle the search in File, the search component is completely destroyed and you loose whatever search term you had in there. You'll also get a Form Schema request each time you toggle the search. #627 Should fix this. The GridField search remember its term when you untoggle it. Another solution could be to only render |
CCers recently added a I think the attached issue was more along the lines of caching schema per object type - so separate forms can use the same cache. Redux-form should remember individual(ly named) forms. |
Just adding to this - I've had a lot of experience recently with not reloading form schema between un/re-mounts so I'm happy to provide assistance to anyone who picks this up - |
It would be great if these calls would only be made once someone actually clicks on the search icon, because currently if you have a couple of gridfields it makes a lot of calls that are not necessary most of the time. |
I've noticed as well that with a lazy-loading gridfield, the searchform gets loaded twice - once when the main edit form is loaded, and again when the gridfield gets loaded. |
in the meantime, for those who don't need search, using this
will remove the calls. I'm not sure there will be a fix anytime soon for this issue since it's deeply related to how the field is implemented. lazy loading could help here as well, but it's not really implemented in a way that is compatible as far as I can see. |
a minor improvement is to add this in the init method public function init()
{
parent::init();
// Optimize search form
if (strpos($this->getRequest()->getURL(), 'schema/SearchForm') !== false) {
session_write_close();
}
} i'm not sure the schema endpoint should depend on the session and if they do, they probably never update it so no need to lock the xhr request behind a session lock |
That hints at a much wider problem with the way Silverstripe framework handles sessions which the hybrid sessions module resolves - Silverstripe framework locks your session for the entirety of each request, and won't accept any more requests from you (i.e. using the same browser window) while processing your request. |
Steps to reproduce
cwp/cwp-recipe-kitchen-sink
In this case, there's a bunch of searchable gridfields added by the comments module.
Ideally these are only loaded if you click on the advanced filters dropdown. I imagine there's a very small number of times people browse to edit a page and intend to use advanced search on a gridfield.
The text was updated successfully, but these errors were encountered: