Skip to content

Commit

Permalink
Refactor #1832 - For MultiSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Mar 1, 2021
1 parent 6c5c82c commit b0793e2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/multiselect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { MultiSelectItem } from './MultiSelectItem';
import { MultiSelectPanel } from './MultiSelectPanel';
import UniqueComponentId from '../utils/UniqueComponentId';
import ConnectedOverlayScrollHandler from '../utils/ConnectedOverlayScrollHandler';
import { PrimeEventBus } from '../utils/PrimeEventBus';

export class MultiSelect extends Component {

Expand Down Expand Up @@ -116,11 +117,19 @@ export class MultiSelect extends Component {
this.onOverlayEntered = this.onOverlayEntered.bind(this);
this.onOverlayExit = this.onOverlayExit.bind(this);
this.onOverlayExited = this.onOverlayExited.bind(this);
this.onPanelClick = this.onPanelClick.bind(this);

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

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

onOptionClick(event) {
let optionValue = this.getOptionValue(event.option);
let selectionIndex = this.findSelectionIndex(optionValue);
Expand Down Expand Up @@ -705,7 +714,7 @@ export class MultiSelect extends Component {
<div className="p-multiselect-trigger">
<span className="p-multiselect-trigger-icon pi pi-chevron-down p-c"></span>
</div>
<MultiSelectPanel ref={this.overlayRef} header={header} appendTo={this.props.appendTo}
<MultiSelectPanel ref={this.overlayRef} header={header} appendTo={this.props.appendTo} onClick={this.onPanelClick}
scrollHeight={this.props.scrollHeight} panelClassName={this.props.panelClassName} panelStyle={this.props.panelStyle}
in={this.state.overlayVisible} onEnter={this.onOverlayEnter} onEntered={this.onOverlayEntered} onExit={this.onOverlayExit} onExited={this.onOverlayExited}>
{items}
Expand Down

0 comments on commit b0793e2

Please sign in to comment.