Hamburger toggle functionality is not working.

Created on 4 October 2023, over 1 year ago

Problem/Motivation

The hamburger toggle functionality is not working. Added a screenshot for reference.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @shweta__sharma
  • Assigned to Shreya_98
  • Issue was unassigned.
  • Assigned to anish.ir
  • Hi,

    I encountered an issue where the hamburger menu in the theme was not working correctly. After debugging, I discovered that the JavaScript files required for the functionality were not being loaded due to incorrect paths. Specifically, the plugin_path variable in the test.js file was pointing to the custom folder instead of the contrib folder. So, whenever we install the site it is installed in the '/themes/contrib/' rather than '/themes/custom/'.

    Hereโ€™s a summary of the issue and resolution:

    Issue:

    • The JavaScript files, including bootstrap.min.js and jquery.flot.min.js, were not loading.
    • The browser console showed MIME type errors and 404 errors for the JS files.
    • The incorrect path in the plugin_path variable was causing the system to look for files in /themes/custom/smarty_admin/ instead of /themes/contrib/smarty_admin/.

    Resolution:

    • I updated the plugin_path variable in the test.js file to: var plugin_path = '/themes/contrib/smarty_admin/assets/plugins/'
    • After this change, the JS files were correctly loaded, and the hamburger menu started working as expected.

    Recommendation:

    Please update the test.js file in the theme to ensure the correct path (contrib instead of custom) is used for plugin_path.
    Alternatively, consider making the path dynamic to avoid hard-coding issues in the future.

    Currently, I am raising the MR with the changes and attaching the screenshots along with the error Let me know if you need any further details or assistance.
    Thanks!

  • Pipeline finished with Success
    about 2 months ago
    Total: 2646s
    #402459
  • Hi,

    As mentioned earlier, the issue with the hamburger menu not working was due to incorrect paths in the plugin_path variable in test.js, which pointed to /themes/custom/ instead of /themes/contrib/.

    I resolved this by dynamically setting the theme path in drupalSettings using the following approach:

    $theme_path = \Drupal::service('extension.list.theme')->getPath(\Drupal::theme()->getActiveTheme()->getName());
    $variables['#attached']['drupalSettings']['smartyAdmin'] = [
      'themePath' => '/' . $theme_path,
    ];

    Updated test.js to:
    var plugin_path = drupalSettings.smartyAdmin.themePath + '/assets/plugins/';
    This ensures the correct path is used dynamically, avoiding hardcoding issues. Now, whatever the path of the theme be, the scripts will load dynamically.
    I've raised an MR with the changes.

    Thanks!

  • Pipeline finished with Success
    about 2 months ago
    Total: 701s
    #404540
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hetal.solanki

    @anish.ir

    I have review MR!5. It's working for me.

    Moving to RTBC.

    Thank you!!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia jaydeep_patel Ahmedabad

    Merged.
    Thank you @shweta__sharma, @anish.ir and @hetal.solanki for your contribution.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia jaydeep_patel Ahmedabad
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024