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

Exporting context button does not close when clicked. #4377

Closed
WilliamBaldwinIII opened this Issue Jul 10, 2015 · 6 comments

Comments

Projects
None yet
4 participants
@WilliamBaldwinIII

WilliamBaldwinIII commented Jul 10, 2015

After opening the exporting context button, it does not close when clicked as would be expected. I have a fix!

If we add the line of code:

// Hide it on clicking on the context menu button again.
addEvent(menu, 'click', hide);

on line 527 right after

// Hide it on clicking or touching outside the menu (#2258, #2335, #2407)
addEvent(document, 'mouseup', docMouseUpHandler);
addEvent(chart, 'destroy', function () {
    removeEvent(document, 'mouseup', docMouseUpHandler);
});

in the contextMenu function of exporting.js, it fixes the issue.

@gvaartjes

This comment has been minimized.

Collaborator

gvaartjes commented Jul 13, 2015

Please explain what you're expecting to be default behaviour.

Now it supposed to close when:

  1. You pressed a menu item, like 'Download as PNG'
  2. When you click outside the export menu

If this isn't the case please report also your browser + version

@WilliamBaldwinIII

This comment has been minimized.

WilliamBaldwinIII commented Jul 13, 2015

I would expect default behavior to be closing when I click on the context button again.

For example, in Google Chrome, if we click the context button at the top right, the menu opens. If we click it again, the menu closes.

@gvaartjes

This comment has been minimized.

Collaborator

gvaartjes commented Jul 13, 2015

Ok, I see your point. Thanks

@gvaartjes

This comment has been minimized.

Collaborator

gvaartjes commented Jul 13, 2015

Add an eventhandler to the button, when the user clicks the export context button the menu is expected to disappear.

@aviramga

This comment has been minimized.

aviramga commented Jun 25, 2018

I still have this issue so I guess this wasnt fixed yet :)
Is there a workaround for now?

@pawelfus

This comment has been minimized.

Contributor

pawelfus commented Jun 25, 2018

Yes, this issue is still open :)

Workaround:
Demo: https://jsfiddle.net/BlackLabel/06nbf9uw/

Plugin:

(function(H) {
  H.wrap(H.Chart.prototype, 'contextMenu', function(proceed, className) {
    var chart = this,
      name = 'cache-' + className,
      menu = chart[name],
      isNew = !menu;

    // Call default method:
    proceed.apply(this, Array.prototype.slice.call(arguments, 1));

    menu = chart[name];

    // Add event only once:
    if (isNew && menu) {

      chart.exportEvents.push(
        H.addEvent(menu, 'click', function() {
          var menu = chart['cache-highcharts-contextmenu'];
          if (menu && chart.openMenu) {
            // Hide context menu:
            chart.openMenu = false;
            H.css(menu, {
              display: 'none'
            });
          }
        })
      );
    }
  });
})(Highcharts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment