Environment

  • Drupal Version: 9.4.9
  • Web Server: Apache/2.4.54 (Unix) LibreSSL/3.3.6
  • PHP/7.4.33
  • DatabaseVersion: 8.0.30

Problem/Motivation

Motivation: Update to latest recommended version.
Problem: after update to Recommended version:8.x-1.0-rc1 (2022-Nov-29), jump menu stopped working.

Steps to reproduce

1. Used composer to update Views Jump Menu
from8.x-1.0-beta3
to Recommended version:8.x-1.0-rc1 (2022-Nov-29)
2. Performed database update

 ----------------- ----------- --------------- ----------------------------- 
  Module            Update ID   Type            Description                  
 ----------------- ----------- --------------- ----------------------------- 
  views_jump_menu   8101        hook_update_n   8101 - Adds the new_window   
                                                config key to existing jump  
                                                menu configurations.         
 ----------------- ----------- --------------- ----------------------------- 


 Do you wish to run the specified pending updates? (yes/no) [yes]:
 > yes

3. cleared cache
4. accessed page where views jump menu is located and perform a search.
*RESULT:* after entering a keyword in the search box, it stopped bringing back results after entering search term

Temp solution:

Rolling back changes to 8.x-1.0-beta3 made it work again.

*NOTE* after rolling back, performing a database update did not bring any change to the database

sudo drush updatedb
 [success] No pending updates.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

La558 created an issue. See original summary.

la558’s picture

Issue summary: View changes
david.qdoscc’s picture

I'm experiencing the same issue. The search box filters the list correctly, but clicking on any of the results does not then jump to the selected page. I also reverted to 1.0-beta3 to get it working again.

la558’s picture

Hello,
Do you have any update on this issue?

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

The bug reports seem to be about different problems. One being that search didn't return any results, the other in #3 that search did provide results but the redirect didn't happen.

To be honest, there's not enough information to know what exactly are the problems here. The module did change how it calculates where to jump to, and it is very possible that #3 was depending on the previous buggy functionality to work properly.

We need you to investigate the reason for the problem or provide a link to the site with the bug and document why it doesn't work, not simply that it doesn't work, as that is unfortunately not enough information.

la558’s picture

thanks for your response.

As you can understand, I cannot push this change to our production site because because searching stopped working after applying this update.

Sorry, if I missed to provide further information.
What would you like me to add?
Screenshots?

la558’s picture

Adding some screenshots and the JavaScript error.

*Behavior:*
1. enter the search term in the search box; as I'm typing in, possible matching results start coming up
2. select one among the different options

*on Views Jump Menu 8.x-1.0-beta3: everything works fine *
3. Content related to the selected entry is displayed.

Only local images are allowed.

*not working after running the update: 8.x-1.0-rc1*
3. nothing happens

*JavaScript error*

Uncaught TypeError: Cannot read properties of undefined (reading '0')
    at HTMLDivElement.<anonymous> (js_AGj_MdwWXLcI170I02GPhXtMccyaLgHiDBs5DxFEGsY.js:5599:54)
(anonymous) @ js_AGj_MdwWXLcI170I02GPhXtMccyaLgHiDBs5DxFEGsY.js:5599

extract of JS code that it's referenced in the erro:

Line 5599 is

            const destination = element.selectedOptions[0].dataset.url;

full function:

  /**
   * @file
   * Attaches the behaviors for the Views-Jump-Menu module.
   */
  
  (function (Drupal) {
    'use strict';
  
    Drupal.behaviors.viewsJumpMenu = {
      attach: function (context, settings) {
        context.querySelectorAll('.js-viewsJumpMenu').forEach(function (element) {
          element.addEventListener('change', function () {
            const currentJumpMenuId = this.getAttribute('id');
            const destination = element.selectedOptions[0].dataset.url;
  
            if (currentJumpMenuId && settings.viewsJumpMenu[currentJumpMenuId]['new_window']) {
              window.open(destination, '_blank', 'noopener');
              this.selectedIndex = '';
            }
            else {
              window.location = destination;
            }
          });
        });
      }
    };
  })(Drupal);
  ;
la558’s picture

tried uploading images, but I'm not being able to do so.

la558’s picture

*NOTE*
could it be that the problem is that I'm using this module in conjunction with the chosen module?

david.qdoscc’s picture

In my case, I am not using the Chosen module, but I am using Select2. If I uninstall Select2 the jump menu works, however we lose the search function which is a critical feature for us. So it may be that after 8.x-1.0-beta3 this module no longer works with Chosen or Select2?

I have also tested with the patch #22 from Integration with chosen or select2 js but it still doesn't work.

la558’s picture

I've also tested it with the patch #22 from Integration with chosen or select2 without success.

jcnventura’s picture

Yes, it seems clear to me that the selectedOptions array for change event listener on the .js-viewsJumpMenu selector is not set when using chosen or select2. This probably because those packages are changing that element in ways that I wasn't expecting it to change when testing this code. Maybe it is possible to narrow down the event listener to work only when selecting one option. Or maybe harden the code to skip the entire processing if selectedOptions is empty.

In any case, it seems that the module works fine with chosen or select2 even without the patch in #3077459: Integration with chosen or select2 js. If that is so, I wonder if it even makes any sense to keep that patch around.

fractile81’s picture

StatusFileSize
new881 bytes

In my case, I have Chosen setup with a Views Jump Field element. I have found that changing the vanilla JS back to using jQuery fixed this particular issue. Not saying it's the direction to take it, just posting a work-around.

This is against RC1.

sriharsha.uppuluri made their first commit to this issue’s fork.

sriharsha.uppuluri’s picture

StatusFileSize
new781 bytes

Thank you for the patch; I've successfully ported it, and it's working for me.