Autocomplete filter stops reset button from firing

Created on 5 December 2016, almost 8 years ago
Updated 9 February 2024, 7 months ago

Problem/Motivation

When the Views exposed form gets a validation error, the reset button stop working.

Steps to reproduce

  • In a clean Umami install
  • Create a node view
  • Add an exposed author filter
  • Add a reset button to the exposed form
  • Go to the view page
  • Filter on a non-existing user name
  • See an error
  • Press reset
  • See the name still filled in and the error still on the page

Proposed resolution

Skip validation when using the reset button.

Remaining tasks

Find a good fix.

User interface changes

API changes

Data model changes

Release notes snippet

Original report by @benjamin.merkley

Found this by,
Using a relationship to the "user" you can receive an autocomplete filter, add a reset button, you began to type something incorrectly and hit enter it will provide you with an error, hit reset, It will not fire because the autocomplete wasn't correct.

Tested on Simply test, with just core.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 13 hours ago

Created by

πŸ‡¨πŸ‡¦Canada benjamin.merkley

Live updates comments and jobs are added and updated live.
  • Needs subsystem maintainer review

    It is used to alert the maintainer(s) of a particular core subsystem that an issue significantly impacts their subsystem, and their signoff is needed (see the governance policy draft for more information). Also, if you use this tag, make sure the issue component is set to the correct subsystem. If an issue significantly impacts more than one subsystem, use needs framework manager review instead.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France DYdave

    Thanks a lot everyone for raising this issue, it's greatly appreciated.

    Thanks a lot @Lendude for updating the IS and patch : we've been having the exact same issue.

    The patch from #28 seems to work for us, except for the warning messages popping out after resetting the form, see for example below :

    Error message
    Warning: Undefined array key "title" in Drupal\views\Plugin\views\filter\FilterPluginBase->acceptExposedInput() (line 1498 of core/modules/views/src/Plugin/views/filter/FilterPluginBase.php).
    Drupal\views\Plugin\views\filter\FilterPluginBase->acceptExposedInput(Array) (Line: 183)
    Drupal\views\Form\ViewsExposedForm->submitForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm('views_exposed_form', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm('\Drupal\views\Form\ViewsExposedForm', Object) (Line: 134)
    Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm() (Line: 1253)
    Drupal\views\ViewExecutable->build() (Line: 392)
    Drupal\views\Plugin\views\display\PathPluginBase->execute() (Line: 196)
    Drupal\views\Plugin\views\display\Page->execute() (Line: 1645)
    Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 81)
    Drupal\views\Element\View::preRenderViewElement(Array)
    call_user_func_array(Array, Array) (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 858)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

    See screenshot below :

     

    Which seems to also be part of the reason the tests could have failed at #28.

    If we could perhaps prevent these warning error messages, this patch could potentially become exploitable.

    Therefore, please find attached to this comment an updated patch which prevents warning messages and resets the exposed filters values:
    File attached as: 2833223-29-core-autocomplete-filter-stops-reset-button-from-firing-warning-messages.patch β†’
    Interdiff: interdiff_28-29.txt β†’

    I've tested this with required filters as well and it seemed to work, but this definitely needs help reviewing and testing.

    Honestly, I haven't spent more time than this, looking into finding a more appropriate solution, as suggested by @Lendude, or in the IS, trying to "Skip validation when using the reset button". So I really have no clue whether this is the right way to fix this.
    I've only really tried fixing the symptoms instead of finding the root of the problem.

    Therefore, we would greatly appreciate some help reviewing and testing this updated patch and more particularly whether anyone would see potential regressions or side effects introduced by the change in this patch.

    Thanks in advance for your feedback and comments.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 7 months ago
    Build Successful
  • πŸ‡«πŸ‡·France DYdave

    Therefore, please find attached to this comment an updated patch which prevents warning messages and resets the exposed filters values:
    File attached as: 2833223-33-core-autocomplete-filter-stops-reset-button-from-firing-warning-messages.patch β†’
    Interdiff: interdiff_28-33.txt β†’

    I've tested this with required and grouped filters as well and it seemed to work, but this definitely needs help reviewing and testing.

    Honestly, I haven't spent more time than this, looking into finding a more appropriate solution, as suggested by @Lendude, or in the IS, trying to "Skip validation when using the reset button". So I really have no clue whether this is the right way to fix this.
    I've only really tried fixing the symptoms instead of finding the root of the issue.

    Therefore, we would greatly appreciate some help reviewing and testing this updated patch and more particularly whether anyone would see potential regressions or side effects introduced by the change in this patch.

    Thanks in advance for your feedback and comments.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 8.1 & MySQL 5.7 updated deps
    last update 7 months ago
    Build Successful
  • Status changed to Needs work 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    It is recommended to use MRs as patches are being phased out and DrupalCi is less supported these days.

    But #33 appears to have test failures.

    Did not test or review.

    +        options:
    +          submit_button: Apply
    +          reset_button: true
    +          reset_button_label: Reset
    +          exposed_sorts_label: 'Sort by'
    +          expose_sort_order: true
    +          sort_asc_label: Asc
    +          sort_desc_label: Desc
    

    If this change updates a view config we will need an upgrade path for existing sites.

Production build 0.71.5 2024