When I activate ajax for my views, and enable term autocomplete exposed filter, it looks like that form submit happens too early, when I select some option from autocomplete and hit enter. So, if I write "Пу" and the autocomplete suggests "Пушкин" and I try to select it using my keyboard arrows and enter, the form is submitted with "Пу" and throws validation error. You can reproduce it here:
http://sfera.apcards.ru/catalog
(try to type "Пу" in "Автор" field)

screenshot: http://pix.am/FOGz/

Comments

dawehner’s picture

Status:Active» Postponed (maintainer needs more info)

Can you rebuild this view on a normal english drupal installation so we could try to reproduce the bug and based on this fix the bug?

Everytime an issue is easy to reproduce the bug get's fixed much faster :)

restyler’s picture

http://sfera.apcards.ru/test

Start to type "Ste" in "Author" and when you see "stephen king" select it using keyboard arrows, and press enter.

dawehner’s picture

Can you also please export the view and attach it here? Thanks!

restyler’s picture

$view = new view;
$view->name = 'test';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'test';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'test';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'book' => 'book',
  'product' => 'product',
);
/* Filter criterion: Content: Информация об авторе (field_author) */
$handler->display->display_options['filters']['field_author_tid']['id'] = 'field_author_tid';
$handler->display->display_options['filters']['field_author_tid']['table'] = 'field_data_field_author';
$handler->display->display_options['filters']['field_author_tid']['field'] = 'field_author_tid';
$handler->display->display_options['filters']['field_author_tid']['value'] = '';
$handler->display->display_options['filters']['field_author_tid']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_author_tid']['expose']['operator_id'] = 'field_author_tid_op';
$handler->display->display_options['filters']['field_author_tid']['expose']['label'] = 'Author';
$handler->display->display_options['filters']['field_author_tid']['expose']['operator'] = 'field_author_tid_op';
$handler->display->display_options['filters']['field_author_tid']['expose']['identifier'] = 'field_author_tid';
$handler->display->display_options['filters']['field_author_tid']['reduce_duplicates'] = 0;
$handler->display->display_options['filters']['field_author_tid']['vocabulary'] = 'authors';
$handler->display->display_options['filters']['field_author_tid']['error_message'] = 1;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'test';

dawehner’s picture

$handler->display->display_options['filters']['field_author_tid']['id'] = 'field_author_tid';
$handler->display->display_options['filters']['field_author_tid']['table'] = 'field_data_field_author';
$handler->display->display_options['filters']['field_author_tid']['field'] = 'field_author_tid';
$handler->display->display_options['filters']['field_author_tid']['value'] = '';
$handler->display->display_options['filters']['field_author_tid']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_author_tid']['expose']['operator_id'] = 'field_author_tid_op';
$handler->display->display_options['filters']['field_author_tid']['expose']['label'] = 'Author';
$handler->display->display_options['filters']['field_author_tid']['expose']['operator'] = 'field_author_tid_op';
$handler->display->display_options['filters']['field_author_tid']['expose']['identifier'] = 'field_author_tid';
$handler->display->display_options['filters']['field_author_tid']['reduce_duplicates'] = 0;
$handler->display->display_options['filters']['field_author_tid']['vocabulary'] = 'authors';
$handler->display->display_options['filters']['field_author_tid']['error_message'] = 1;

The problem here is that you would have to create the fields manually and make some mistakes there as well.
Additonal this doesn't improve the motiviation to focus on this issue.

restyler’s picture

I don't get your comment, sorry.
can you please re-phrase?

restyler’s picture

Title:Taxonomy autocomplete + ajax view = error» Views exposed autocomplete + ajax view = form submit happens too early
restyler’s picture

just reproduced the bug again in different situation: textfield field in node, text exposed filter + autocomplete added to the textfield by form_alter hook.

dawehner’s picture

So the problem is probably that the focus is not on the autocomplete but on the actual submit element.

The prober fix would be perhaps that drupal autocomplete set's the focus manually

esmerel’s picture

Status:Postponed (maintainer needs more info)» Active
ichionid’s picture

Hey I have the similar issue! Any update or workaround to it?

reeller_sk’s picture

Same issue here, I tried to add autocomplete to 'tlp_full_name_value' exposed filter in hook_form_views_exposed_form_alter, autocomplete works ok, but when I select a value from autocomplete popup and hit enter, the form is automatically submitted and the selected value isn't used. After ajax load in filter is not selected value but original value. For example I write 'adm' and autocomplete suggest in popup 'Administrator' I select this value and hit enter, after ajax load the value in filter is automatically changed back to 'adm'. I think problem is that the submit is processed before set of the selected value in the popup.

/**
* Implements hook_form_FORM_ID_alter().
*/
function tl_user_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'views-exposed-form-partner-admin-block-partnership-requests' ||
      $form['#id'] == 'views-exposed-form-partner-admin-block-partner-staff-requests' ||
      $form['#id'] == 'views-exposed-form-partner-admin-page') {
    $form['tlp_full_name_value']['#autocomplete_path'] = 'ajax/autocomplete/name';
  }
}

Exported view code: http://pastebin.com/Tx2Esr9k

reeller_sk’s picture

Version:7.x-3.x-dev» 7.x-3.3
Component:taxonomy data» Views Form
pcrats33’s picture

Issue summary:View changes

There is a cTools patch that fixes this: https://www.drupal.org/node/1708438

Drif.io’s picture

Unfortunately came across this issue on a project I'm currently working on. The solution I found was to call Drupal.autocompleteSubmit (in autocomplete.js) within Drupal.ajax.prototype.beforeSerialize (in ajax.js) in order to populate the textbox BEFORE the form is serialized. This solved the issue for me, but doesn't feel like an ideal solution. If anyone has a better suggestion I'm all ears.