Skip to content

Commit

Permalink
Refactor #1832 - For TieredMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Mar 1, 2021
1 parent 725b44f commit d23d9fb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/tieredmenu/TieredMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TieredMenuSub } from './TieredMenuSub';
import { CSSTransition } from 'react-transition-group';
import UniqueComponentId from '../utils/UniqueComponentId';
import ConnectedOverlayScrollHandler from '../utils/ConnectedOverlayScrollHandler';
import { PrimeEventBus } from '../utils/PrimeEventBus';

export class TieredMenu extends Component {

Expand Down Expand Up @@ -46,11 +47,21 @@ export class TieredMenu extends Component {
this.onEnter = this.onEnter.bind(this);
this.onEntered = this.onEntered.bind(this);
this.onExit = this.onExit.bind(this);
this.onPanelClick = this.onPanelClick.bind(this);

this.id = this.props.id || UniqueComponentId();
this.menuRef = React.createRef();
}

onPanelClick(event) {
if (this.props.popup) {
PrimeEventBus.emit('overlay-click', {
originalEvent: event,
target: this.target
});
}
}

toggle(event) {
if (this.props.popup) {
if (this.state.visible)
Expand Down Expand Up @@ -178,7 +189,7 @@ export class TieredMenu extends Component {
return (
<CSSTransition nodeRef={this.menuRef} classNames="p-connected-overlay" in={this.state.visible} timeout={{ enter: 120, exit: 100 }}
unmountOnExit onEnter={this.onEnter} onEntered={this.onEntered} onExit={this.onExit}>
<div ref={this.menuRef} id={this.id} className={className} style={this.props.style}>
<div ref={this.menuRef} id={this.id} className={className} style={this.props.style} onClick={this.onPanelClick}>
<TieredMenuSub model={this.props.model} root popup={this.props.popup} />
</div>
</CSSTransition>
Expand Down

0 comments on commit d23d9fb

Please sign in to comment.