Clicking on the "Expose this filter to visitors, to allow them to change it" immediately after adding a filter to a view results in returning to the list of things to that can be filtered rather than loading the exposed filter options form.

  1. Steps to reproduce (with standard profile and javascript enabled in the browser):
  2. Goto to admin/structure/views/view/user_admin_people
  3. Click on the add button next to "Filter criteria"
  4. Check any filter eg. "File Usage: Entity ID" and click "Add and configure filter criteria"
  5. Click on the "Expose this filter to visitors, to allow them to change it" checkbox

results in the unexpected behaviour

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott’s picture

After adding the filter the form action is still set to /admin/structure/views/ajax/add-handler/user_admin_people/page_1/filter. I think what should happen is that the form action should be set to /admin/structure/views/ajax/handler/user_admin_people/page_1/filter/FILTER_ID and then it work just fine. But this might not work - since you can add more than one filter at once.

olli’s picture

Status: Active » Needs review
FileSize
2.73 KB

This seems to fix it.

Khetam’s picture

I am using drupal 8.0.0-beta2 version and It's working fine with me :) :) :)

Thanks,
Khetam.

olli’s picture

FileSize
4.02 KB
1.29 KB

Same problem with sort criteria.

vijaycs85’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

thanks for the patch @olli. Would be great to have a test-only failing patch.

One minor comment:

+++ b/core/modules/views_ui/js/views-admin.js
@@ -865,7 +865,7 @@
+      .trigger('mousedown')

Mousedown? why not leave it as click? if we have to, then the handler name should be changed as well.

olli’s picture

FileSize
4.78 KB
778 bytes

Same problem with the "Remove" button when adding a filter.

Would be great to have a test-only failing patch.

I agree, but not sure how.

Mousedown? why not leave it as click?

Using click makes the ajax trigger when you hit enter, see comments in RenderElement::preRenderAjaxForm(). This happens in HEAD currently.

the handler name should be changed as well

Drupal.viewsUi.Checkboxifier.prototype.clickHandler? That's for the checkbox, not the button.

Now I see that this changes nearly all of #2130205: Unable to "Expose this filter to visitors, to allow them to change it"... It looks like d7 views ui makes these ajax buttons work via javascript but that code has been removed from d8.

olli’s picture

+++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php
@@ -172,10 +172,10 @@ public function buildForm(array $form, FormStateInterface $form_state) {
+      if ($form_state->get('ajax')) {
+        $form['actions']['remove']['#ajax']['path'] = $form_state->get('path');
+      }

It would be nice to move this fix up to ViewsFormBase or somewhere.

olli’s picture

Here's another patch that is about how d7 views ui seems to work.

metzlerd’s picture

Status: Needs review » Closed (duplicate)

Duplicate of #2248223: Adding a new Views filter and making it exposed returns user back to list of filters. If appropriate it would probably good to file patches there.