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

OverlayMask onClick error #260

Closed
snide opened this issue Jan 4, 2018 · 1 comment · Fixed by #261
Closed

OverlayMask onClick error #260

snide opened this issue Jan 4, 2018 · 1 comment · Fixed by #261
Labels

Comments

@snide
Copy link
Contributor

snide commented Jan 4, 2018

Looks like the portal PR #254 introduced a bug where onClick events can't be used on the overlay mask now. This broke some functionality (essentially the ability to click a flyout to close it).

Steps to replicate

  1. Pull latest
  2. Go to the flyout example. http://localhost:8030/#/flyout
  3. Open the last example "Flyout sizing and focus"
  4. Click the overlaymask that is generated. You'll get a console error of Uncaught SyntaxError: Unexpected token (

cc @nreese

@snide snide added the bug label Jan 4, 2018
@nreese
Copy link
Contributor

nreese commented Jan 4, 2018

    Object.keys(rest).forEach((key) => {
      this.overlayMaskNode.setAttribute(key, rest[key]);
    });

overlay_mask.js line 27 - setAttribute is the culprit. Setting the onClick as an attribute does not properly attach the event handler function.

Manually handling the onClick property gets things working but I am not sure this is the best solution. We will be playing wack-a-mole forever with each new attribute. Any ideas how to better add react props to a dom node?

  constructor(props) {
    super(props);

    const {
      className,
      children, // eslint-disable-line no-unused-vars
      onClick,
      ...rest
    } = this.props;

    this.overlayMaskNode = document.createElement('div');
    this.overlayMaskNode.className = classNames(
      'euiOverlayMask',
      className
    );
    if (onClick) {
      this.overlayMaskNode.onclick = onClick;
    }
    Object.keys(rest).forEach((key) => {
      this.overlayMaskNode.setAttribute(key, rest[key]);
    });
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants