I have setup a view with ajax enabled. I have also added an exposed filter with autosubmit on so that as the user types in the text field the view will automatically update. The problem is that when the form autosubmits, the text box loses focus.

I have read that I need to separate the exposed form into a separate block, however this option is not available as my view is a block itself.

Any help would be appreciated, as it is a real pain having to keep clicking in the text box to keep typing.

  • 3
    This is a known problem: drupal.org/node/1217948 and is not that easy to fix Commented Sep 24, 2012 at 10:17
  • Can you do a exposed_filter_alter to manually change values and add your own javascript? Commented Apr 4, 2013 at 9:36

2 Answers 2


Also a workaround for the core problem, but including this js in my theme solved this problem for me.


You really only have one choice here.

One way or another you need to (re)move your form out of the views.

The reason why the exposed filter looses focus is because the entire view is being replaced on ajax. If your form is being render by the same view there's just no way you're going to be able to keep focus.

Solutions (All involve moving your form out of the view):

Below are some options you should avoid, but mentioning here as a last resort.

  • You can always just "hack" your views.tpl.php to move your expose form out of the main view div. I use "hack" here because this is not a nice option. This will place the form right above your view, but views JS code is only going to replace the view div. That being said the JS isn't going to just work. You'll need to fix that.

  • Then as a last resort you can always just use JS to move your form. This one is highly discourage. Because again the form is going to loose the JS behaviors after views updates the display

  • Just in case anyone else was wondering, I believe the solution recommended here by @ericduran to select Views' option to put "exposed form in block" is just available if the view is of a page (it's not available for a view as block). Commented Jul 19, 2018 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.