From 8394afbac50b4aee643e6b4b6133d260cfa83129 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Thu, 12 Mar 2020 14:00:15 +0300 Subject: [PATCH] Fixed #1248 - onClose of GrowlMessage is also allowing onClick to fire --- src/components/growl/Growl.js | 2 +- src/components/growl/GrowlMessage.js | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/growl/Growl.js b/src/components/growl/Growl.js index 86021d9950..ff01a15a10 100644 --- a/src/components/growl/Growl.js +++ b/src/components/growl/Growl.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import {GrowlMessage} from './GrowlMessage'; import DomHandler from '../utils/DomHandler'; -import { CSSTransition, TransitionGroup } from 'react-transition-group'; +import {CSSTransition, TransitionGroup} from 'react-transition-group'; var messageIdx = 0; diff --git a/src/components/growl/GrowlMessage.js b/src/components/growl/GrowlMessage.js index 0a74351c99..738ab58272 100644 --- a/src/components/growl/GrowlMessage.js +++ b/src/components/growl/GrowlMessage.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; +import DomHandler from '../utils/DomHandler'; export class GrowlMessage extends Component { @@ -37,7 +38,7 @@ export class GrowlMessage extends Component { } } - onClose(event) { + onClose() { if (this.timeout) { clearTimeout(this.timeout); } @@ -45,14 +46,10 @@ export class GrowlMessage extends Component { if (this.props.onClose) { this.props.onClose(this.props.message); } - - if (event) { - event.preventDefault(); - } } - onClick() { - if (this.props.onClick) { + onClick(event) { + if (this.props.onClick && !(DomHandler.hasClass(event.target, 'p-growl-icon-close') || DomHandler.hasClass(event.target, 'p-growl-icon-close-icon'))) { this.props.onClick(this.props.message); } }