Problem/Motivation

Make a change to a view such as changing the label for a field, and the top dropbutton gets ornery

Proposed resolution

Fix it so the dropbutton works in the manner we expect dropbuttons to work.

Remaining tasks

Fix the bug, get it reviewed, commit.

User interface changes

A not-broken dropbutton in views.

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

CommentFileSizeAuthor
#24 interdiff.txt6.17 KBlauriii
#24 3067085-24.patch10.01 KBlauriii
#24 3067085-24-test-only.patch4.07 KBlauriii
#21 claro-views_ui_menu_tabs-3067085-21--complete.patch10.98 KBhuzooka
#21 claro-views_ui_menu_tabs-3067085-21--test-only.patch5.04 KBhuzooka
#21 interdiff-3067085-16-21.txt1.3 KBhuzooka
#19 claro-views_ui_menu_tabs-3067085-19--complete.patch19.2 KBhuzooka
#19 claro-views_ui_menu_tabs-3067085-19--test-only.patch5.04 KBhuzooka
#19 interdiff-3067085-16-19.txt1.3 KBhuzooka
#16 interdiff-3067085-14-16.txt842 byteshuzooka
#16 claro-views_ui_menu_tabs-3067085-16--complete.patch11.34 KBhuzooka
#14 interdiff-3067085-13-14.txt5.83 KBhuzooka
#14 claro-views_ui_menu_tabs-3067085-14--complete.patch11.23 KBhuzooka
#13 interdiff-3067085-9-13.txt4.16 KBhuzooka
#13 claro-views_ui_menu_tabs-3067085-13--test-only.patch5.39 KBhuzooka
#9 interdiff-3067085-8-9.txt891 byteshuzooka
#9 claro-views_ui_menu_tabs-3067085-9--test-only.patch3.11 KBhuzooka
#8 claro-views_ui_menu_tabs-3067085-8--test-only.patch3.28 KBhuzooka
unpleasant-dropbutton-in-views.png321.55 KBbnjmnm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bnjmnm created an issue. See original summary.

bnjmnm’s picture

This appears to be due to claro_form_view_edit_form_alter not being called when the Views UI is rebuilt via Ajax. Commenting here in case someone reading this already has an idea how to best go about addressing this.

bnjmnm’s picture

Setting to postponed - after working on this I believe it is actually a Views UI issue, and I created an issue (with patch and test) #3067386: AJAX rebuild of Views UI form re-renders parts of the form without using Form API, so additional hooks are needed in lieu of hook_form_view_edit_form_alter()
Leaving this open but postponed in case this is addressable with Claro, or if the Views UI fix does not fully address the symptoms.

huzooka’s picture

andypost’s picture

huzooka’s picture

Project: Claro » Drupal core
Version: 8.x-1.x-dev » 8.9.x-dev
Component: Code » Claro theme
huzooka’s picture

Assigned: Unassigned » huzooka
Status: Postponed » Active
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Active » Needs review
FileSize
3.28 KB

Added a test for the Views UI Menu Tabs. (It does not tests the currently broken dropbutton.)

The test tries to verify that the views-tabs and the views-tabs--secondary CSS classes can be found on the view ui menu tabs element even before and after an AJAX refresh.

huzooka’s picture

The last submitted patch, 8: claro-views_ui_menu_tabs-3067085-8--test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 9: claro-views_ui_menu_tabs-3067085-9--test-only.patch, failed testing. View results

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
FileSize
11.23 KB
5.83 KB

Technically I only applied the patch that I got from @lauriii.

#13 added a new test case for the extra actions dropbutton.

huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work

From @lauriii:

you need to make some docs fixes in the patch at least

the patch I sent is not complete

He's totally right.

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
FileSize
11.34 KB
842 bytes
lauriii’s picture

Status: Needs review » Needs work
  1. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
    @@ -0,0 +1,125 @@
    +   * Install the shortcut module so that claro.settings has its schema checked.
    +   * There's currently no way for Claro to provide a default and have valid
    +   * configuration as themes cannot react to a module install.
    

    This documentation seems unrelated.

  2. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
    @@ -0,0 +1,125 @@
    +    // Install Claro and set it as admin theme.
    +    $this->container->get('theme_installer')->install(['claro']);
    +    $this->config('system.theme')->set('admin', 'claro')->save();
    

    Are we able to use the new $defaultTheme property for setting Claro as the testing theme?

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

huzooka’s picture

Status: Needs review » Needs work
huzooka’s picture

phenaproxima’s picture

Status: Needs review » Needs work

Nice work! I began by reading the test-only patch, and found some things that should probably be changed to make it more reliable and less verbose. 🤓

  1. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
    @@ -0,0 +1,121 @@
    +    $display_menu_tabs_css_selector = '#views-display-menu-tabs';
    +    $page = $this->getSession()->getPage();
    +    $display_menu_tabs = $page->find('css', $display_menu_tabs_css_selector);
    +    $this->assertNotEmpty($display_menu_tabs);
    +    $this->assertTrue($display_menu_tabs->hasClass('views-tabs'));
    +    $this->assertTrue($display_menu_tabs->hasClass('views-tabs--secondary'));
    

    This can basically be all one line:

    $display_menu_tabs = $this->assertSession()->elementExists('css', '#views-display-menu-tabs.views-tabs.views-tabs--secondary');
    
  2. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
    @@ -0,0 +1,121 @@
    +    $display_name_link = $page->find('css', '#edit-display-settings-top .views-display-setting a');
    +    $this->assertNotEmpty($display_name_link);
    +    $display_name_link->click();
    

    This could also be one line, since WebAssert::elementExists() returns the element in question:

    $this->assertSession()->elementExists('css', '#edit-display-settings-top .views-display-setting a')->click();
    
  3. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
    @@ -0,0 +1,121 @@
    +    $this->assertSession()->waitForElement('css', '.js-views-ui-dialog');
    

    This is an incorrect use of waitForElement(). It returns a boolean, but does not actually assert that the element appeared. So, this needs to be:

    $this->assertTrue($this->assertSession()->waitForElement('css', '.js-views-ui-dialog'));

  4. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
    @@ -0,0 +1,121 @@
    +    $apply_button = $page->find('css', '.js-views-ui-dialog .ui-dialog-buttonpane')->findButton('Apply');
    +    $this->assertNotEmpty($apply_button);
    +    $apply_button->press();
    

    Again, this can be more assertive as a single line:

    $this->assertSession()->elementExists('css', '.js-views-ui-dialog .ui-dialog-buttonpane')->pressButton('Apply');

  5. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
    @@ -0,0 +1,121 @@
    +    // Wait for AJAX to finish.
    +    $this->assertSession()->assertWaitOnAjaxRequest();
    

    assertWaitOnAjaxRequest() is bad news and should not be relied upon. However, I see that in this case we probably will not be able to do anything else, so no need to change this. But in general, one should wait on the expected condition, rather than the more nebulous "an AJAX request has finished".

lauriii’s picture

Status: Needs work » Needs review
FileSize
4.07 KB
10.01 KB
6.17 KB

This should address all feedback from #23 😇

The last submitted patch, 24: 3067085-24-test-only.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

The split of claro_form_view_edit_form_alter() into the two new hooks looks great.

In the first, $form['displays']['top'] is replaced with $element, no other changes.
In the second, $form['displays']['settings']['settings_content']['tab_content'] is replaced with $element, no other changes.

  1. +++ b/core/themes/claro/claro.theme
    @@ -521,69 +521,72 @@ function claro_form_media_form_alter(&$form, FormStateInterface $form_state) {
    +function claro_views_ui_display_top_alter(&$element) {
    ...
    +function claro_views_ui_display_tab_alter(&$element) {
    

    Technically that function signature should read &$build, ViewUI $view, $display_id

    I don't know that it matters, thought I'd call it out.

  2. +++ b/core/themes/claro/claro.theme
    @@ -521,69 +521,72 @@ function claro_form_media_form_alter(&$form, FormStateInterface $form_state) {
    +  // We process the dropbutton-like element on views edit form's
    +  // display settings top section.
    +  //
    +  // That element should be a regular Dropbutton.
    +  //
    +  // After that the reported issue is fixed and the element is rendered with
    +  // the Dropbutton type, we just have to set it's '#dropbutton_type' to
    +  // 'extrasmall'.
    +  //
    +  // @todo: revisit after https://www.drupal.org/node/3057577 is fixed.
    

    I've never seen a docblock with newlines like that, but phpcs isn't flagging it, so I guess it's okay.

effulgentsia’s picture

Adding reviewer credit.

  • effulgentsia committed a19acbd on 9.0.x
    Issue #3067085 by huzooka, lauriii, bnjmnm, tim.plunkett, phenaproxima:...

  • effulgentsia committed 3d84ed1 on 8.9.x
    Issue #3067085 by huzooka, lauriii, bnjmnm, tim.plunkett, phenaproxima:...
effulgentsia’s picture

Status: Reviewed & tested by the community » Fixed

Pushed to 9.0.x and 8.9.x.

If someone wants to take up either or both of the items in #26 in a followup, go for it.

I'll open a separate issue for cherry picking all the 8.9 Claro related commits to 8.8.

  • effulgentsia committed 3c5251b on 8.8.x
    Issue #3067085 by huzooka, lauriii, bnjmnm, tim.plunkett, phenaproxima:...
effulgentsia’s picture

Version: 8.9.x-dev » 8.8.x-dev

Pushed to 8.8.x. See #3088437: Cherry pick Claro to Drupal 8.8. for details.

Status: Fixed » Closed (fixed)

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