Skip to content

Commit

Permalink
Fixed #2171 - Dropdown filter closing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jul 7, 2021
1 parent ac63d4e commit 3dd7e54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/components/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class Dropdown extends Component {
};

this.onClick = this.onClick.bind(this);
this.onFilterContainerClick = this.onFilterContainerClick.bind(this);
this.onInputFocus = this.onInputFocus.bind(this);
this.onInputBlur = this.onInputBlur.bind(this);
this.onInputKeyDown = this.onInputKeyDown.bind(this);
Expand Down Expand Up @@ -170,7 +169,10 @@ export class Dropdown extends Component {
return;
}

if (!this.isClearClicked(event) && event.target.tagName !== 'INPUT') {
if (DomHandler.hasClass(event.target, 'p-dropdown-clear-icon') || event.target.tagName === 'INPUT') {
return;
}
else if (!this.overlayRef.current || !(this.overlayRef.current && this.overlayRef.current.contains(event.target))) {
this.focusInput.focus();

if (this.state.overlayVisible) {
Expand All @@ -182,10 +184,6 @@ export class Dropdown extends Component {
}
}

onFilterContainerClick(event) {
event.stopPropagation();
}

onInputFocus(event) {
event.persist();

Expand Down
2 changes: 1 addition & 1 deletion src/components/dropdown/DropdownPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class DropdownPanelComponent extends Component {
const containerClassName = classNames('p-dropdown-filter-container', { 'p-dropdown-clearable-filter': !!clearIcon });
return (
<div className="p-dropdown-header">
<div className={containerClassName} onClick={this.onFilterContainerClick}>
<div className={containerClassName}>
<input ref={(el) => this.filterInput = el} type="text" autoComplete="off" className="p-dropdown-filter p-inputtext p-component" placeholder={this.props.filterPlaceholder}
onKeyDown={this.props.onFilterInputKeyDown} onChange={this.onFilterInputChange} value={this.props.filterValue} />
{clearIcon}
Expand Down

0 comments on commit 3dd7e54

Please sign in to comment.