Skip to content

Commit a83fddc

Browse files
moonjy1993Moon, Sandy
authored andcommitted
feat: Accept DropdownAlways as a props (#239)
1 parent eccef1c commit a83fddc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class DropdownTreeSelect extends Component {
2828
keepOpenOnSelect: PropTypes.bool,
2929
placeholderText: PropTypes.string,
3030
showDropdown: PropTypes.bool,
31+
showDropdownAlways: PropTypes.bool,
3132
className: PropTypes.string,
3233
onChange: PropTypes.func,
3334
onAction: PropTypes.func,
@@ -53,7 +54,7 @@ class DropdownTreeSelect extends Component {
5354
constructor(props) {
5455
super(props)
5556
this.state = {
56-
showDropdown: this.props.showDropdown || false,
57+
showDropdown: this.props.showDropdown || this.props.showDropdownAlways || false,
5758
searchModeOn: false,
5859
}
5960
this.clientId = props.id || clientIdGenerator.get(this)
@@ -97,7 +98,7 @@ class DropdownTreeSelect extends Component {
9798
handleClick = () => {
9899
this.setState(prevState => {
99100
// keep dropdown active when typing in search box
100-
const showDropdown = this.keepDropdownActive || !prevState.showDropdown
101+
const showDropdown = this.props.showDropdownAlways || this.keepDropdownActive || !prevState.showDropdown
101102

102103
// register event listeners only if there is a state change
103104
if (showDropdown !== prevState.showDropdown) {
@@ -116,7 +117,7 @@ class DropdownTreeSelect extends Component {
116117
}
117118

118119
handleOutsideClick = e => {
119-
if (!isOutsideClick(e, this.node)) {
120+
if (this.props.showDropdownAlways || !isOutsideClick(e, this.node)) {
120121
return
121122
}
122123

0 commit comments

Comments
 (0)