Problem/Motivation

I have a view that renders entities and I use hook_entity_view_mode_alter() to alter the view mode depending on different settings. This works fine. However when I refresh the view through JQuery:
$(myViews).trigger('RefreshView');

the view gets refreshed, but the entity is not rendered anymore using the view mode set by hook_entity_view_mode_alter() but is using the view mode set in views. It seems hook_entity_view_mode_alter() is not executed on refresh.

Steps to reproduce

  • Create a fresh Drupal Install
  • Create a new module (my_module) with the code hook below:
    function my_module_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) {
      $view_mode = 'full';
    }
  • Create a new Tag in the Tags vocabulary
  • Create a new Article (node) using this Tag
  • Update the Taxonomy view to Use Ajax
  • Go to the Taxonomy page to list every articles (/taxonomy/term/1)
  • Run the problematic command jQuery('.view.view-taxonomy-term').trigger('RefreshView');

Proposed resolution

It seems the issue has already beed fixed between 8.5.3 to 8.9.x.

Remaining tasks

  • Try to reproduce the issue
  • write a step-by-step
  • Patch the issue if needs
  • Review

Comments

mike82 created an issue. See original summary.

valthebald’s picture

Version: 8.5.3 » 8.9.x-dev
Issue tags: +Needs issue summary update, +Novice, +Amsterdam2019
mdupont’s picture

I am at DrupalCon Amsterdam and I am looking into this issue.

wengerk’s picture

Hey there ! I'm mentoring - alongside with @mbovan - @mdupont and @hanan_apw at the Drupalcon in Amsterdam 2019.

Phil_b’s picture

Hi there. I´m at DrupalCon in Amsterdam 2019 and i´m helping to solve this issue

hanan alasari’s picture

Status: Active » Needs review

Hi there. I´m at DrupalCon in Amsterdam 2019 and i´m helping to solve this issue.

So i tried:-

  • Fresh Drupal Install
  • Create a new module (my_custom) with the code hook below:
    function my_custom_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) {
      $view_mode = 'full';
    }
  • Create a new Tag in the Tags vocabulary
  • Create a new Article (node) using this Tag
  • Update the Taxonomy view to Use Ajax
  • Go to the Taxonomy page to list every articles (/taxonomy/term/1)
  • Run the problematic command (jQuery('.view.view-taxonomy-term').trigger('RefreshView');)

and seems there is no issue. Its work fine to me.

valthebald’s picture

Can someone update the issue summary, following https://www.drupal.org/node/1155816 as an example?

valthebald’s picture

Status: Needs review » Needs work

After the issue summary is updated, status can be set to Closed (works as expected)

wengerk’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Updated summary as requested.

wengerk’s picture

Status: Needs work » Needs review

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

michaellenahan’s picture

Issue summary: View changes
Issue tags: +Europe2020

Removing Europe2020 tag, since this issue was not worked on at Drupalcon Europe 2020.

michaellenahan’s picture

Issue summary: View changes
Issue tags: -Europe2020
Spokje’s picture

Status: Needs review » Closed (works as designed)

As per #8

After the issue summary is updated, status can be set to Closed (works as expected)

because of updated IS:

It seems the issue has already been fixed between 8.5.3 to 8.9.x.