Coming here from #1904922: Views UI Preview - pager navigation is broken.

Navigation in the UI view preview is not working. This applies to: navigation through clicking links in the pager, clicking a sortable field in a column header of a table view, and clicking 'Apply' after selecting an exposed filter/sort.

Steps to reproduce:
Create 2 nodes
Create a view of nodes, limit to 1, use a pager
Preview the view in the Views UI
Click the "next" link

Expected result:
The second node

Actual result:
A second 'blank' Views UI Preview form, embedded in the Views UI Preview form.

Comments

mondrake’s picture

Status: Active » Needs review
StatusFileSize
new3.46 KB

Start...

This patch would pretty much allow for navigating in the preview. It fixes the duplicate form and allows navigating through pager links, sortable columns, and exposed filters/sorts.

Key points:

  1. in converting from $_REQUEST to the Request object, it looks like we need to take and merge both request() and query() values if we want to get the same results
  2. we may have a challenge with tests here - if we click on the 'Apply' button in exposed filters/sorts, we will get a 'show_preview' key in the form state from the AJAX framework. This is not the case though if we click a link - we will only get a 'js' key in $form_state['input']. This is enough to decide in the form rebuild that we want to re-render the preview, but AFAICS this is a behavior in the live ajax.js, not sure if drupalPostAJAX can mimic the same?
  3. I could not make the preview work with contextual filters - meaning, contextual filter works but it is 'forgotten' if we click on any link. I believe this is due to this piece of code in ViewUI.php
          // Also override the current path so we get the pager.
          $original_path = current_path();
          $q = _current_path($this->override_path);
          if ($args) {
            $q .= '/' . implode('/', $args);
            _current_path($q);
          }
    

    The pager is currently using current_path() to get the URL, and since here we are within the request scope, whatever is in _current_path() will not be used. I understand this is temporary so I will not touch that.

mondrake’s picture

Assigned: mondrake » Unassigned
StatusFileSize
new5.12 KB
new8.59 KB

Here with tests that check if pager navigation within preview is as expected.

Unfortunately, I could not make a test-only that fails in the current context. Apparently live js and emulated ajax in simpletest have different behaviour. In live js, clicking on a link will lead to a POST w/o 'triggering_element' set (just the 'js' = 'true' set in input). In simpletest AJAX, parts of form state are somehow stored in drupalSettings so that even if we do not set a triggering element when we go for a drupalPostAJAX, $form_state['show_preview'] is still available from the previous calls - so the preview is rendered based on this condition (at least that's what I could understand).

mondrake’s picture

#2: 2048309_view-preview_2.patch queued for re-testing.

mondrake’s picture

Priority: Normal » Major

Does this deserve a major priority?

mondrake’s picture

#2: 2048309_view-preview_2.patch queued for re-testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I know that kind of a failing test is kind of important, but consider that the preview has a problems without it, I will RTBC it.

catch’s picture

Status: Reviewed & tested by the community » Fixed

This is the kind of test where Mink/Behat would be so much nicer.

Committed/pushed to 8.x, thanks!

mondrake’s picture

Automatically closed -- issue fixed for 2 weeks with no activity.