Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When setting show_header to false in any view with subpanels it throws javascript errors #8400

Open
marin-h opened this issue Dec 19, 2019 · 1 comment
Labels
Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase

Comments

@marin-h
Copy link

marin-h commented Dec 19, 2019

Setting show_header option to false in any view avoids rendering some specific javascript files and lines.
Particulary when using subpanels in the view, the definitions of js variables UA (which is in _head.tpl) and SUGAR.measurements (in style.js) are missing.
These are used in SubPanelTiles.js and SubPanelTiles.tpl with no previous checking on their value. This throws javascript errors which end up stopping further execution.

Issue

There are two errors but the origin is the same (not rendering the javascript header).
SubPanelTiles.tpl tries to use the js variables SUGAR.measurements and SubPanelTiles.js tries to use js variable UA without checking if these are defined. When they are not defined it throws js errors. See below:

  • SUGAR.measurements use in SubPanelTiles.tpl:
if($(window).width() <= SUGAR.measurements.breakpoints.large) {
            $('.panel-collapse').removeClass('in');
            $('.panel-heading-collapse a').removeClass('in');
            $('.panel-heading-collapse a').addClass('collapsed');
          }
  • UA is used in SUGAR.util.evalScript which is used by got_data function in SubPanelTiles.js when subpanel data is loaded.

Expected Behavior

In a view with subpanels and show_headers set to false no js errors should be thrown.

Actual Behavior

In a view with subpanels and show_headers set to false two js errors are thrown.

Possible Fix

I see two possible solutions:

  • Defining these variables in a separate js and ensuring to render this file in all the views with show_header set to false.
  • Avoiding the use of these variables if they are not defined (this can be useful for SUGAR.measurements which seems expendable, but it's not the case for UA).

Steps to Reproduce

  1. Set show_header option to false in any DetailView.
  2. Set subpaneldefs to show a subpanel.
  3. Access the view.
  4. See the js errors in devtools on the browser:

imagen

Context

When adding some custom js to execute after the subpanel data is fetched and shown, these js errors crash js execution and custom js fails to load.

Your Environment

  • SuiteCRM Version used: 7.10.x.
  • Firefox (64-bit).
  • MySQL, PHP 7.3.
  • Ubuntu 18.04.
@marin-h marin-h changed the title When setting show_header to false in any view SubpanelTiles.tpl throws errors javascript execution When setting show_header to false in any view with subpanels it throws javascript errors Dec 19, 2019
marin-h pushed a commit to gcoop-libre/SuiteCRM that referenced this issue Dec 19, 2019
marin-h pushed a commit to gcoop-libre/SuiteCRM that referenced this issue Dec 19, 2019
@marin-h
Copy link
Author

marin-h commented Dec 19, 2019

I went forward with the first possible solution: adding the definition for these variables when show_header is false.

@Mac-Rae Mac-Rae added the Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution label Feb 4, 2020
@samus-aran samus-aran added the Type: Bug Bugs within the core SuiteCRM codebase label Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

3 participants