diff --git a/webapp/components/more_direct_channels/more_direct_channels.jsx b/webapp/components/more_direct_channels/more_direct_channels.jsx index 46c04c46ef..ab338f68e4 100644 --- a/webapp/components/more_direct_channels/more_direct_channels.jsx +++ b/webapp/components/more_direct_channels/more_direct_channels.jsx @@ -185,11 +185,18 @@ export default class MoreDirectChannels extends React.Component { } } + resetPaging = () => { + if (this.refs.multiselect) { + this.refs.multiselect.resetPaging(); + } + } + search(term) { clearTimeout(this.searchTimeoutId); this.term = term; if (term === '') { + this.resetPaging(); this.onChange(); return; } @@ -203,7 +210,7 @@ export default class MoreDirectChannels extends React.Component { this.searchTimeoutId = setTimeout( () => { - searchUsers(term, teamId); + searchUsers(term, teamId, {}, this.resetPaging); }, Constants.SEARCH_TIMEOUT_MILLISECONDS ); @@ -315,6 +322,7 @@ export default class MoreDirectChannels extends React.Component { { if (this.props.handlePageChange) { this.props.handlePageChange(this.state.page + 1, this.state.page); } @@ -49,7 +41,7 @@ export default class MultiSelect extends React.Component { this.setState({page: this.state.page + 1}); } - prevPage() { + prevPage = () => { if (this.state.page === 0) { return; } @@ -61,11 +53,15 @@ export default class MultiSelect extends React.Component { this.setState({page: this.state.page - 1}); } - onSelect(selected) { + resetPaging = () => { + this.setState({page: 0}); + } + + onSelect = (selected) => { this.selected = selected; } - onAdd(value) { + onAdd = (value) => { if (this.props.maxValues && this.props.values.length >= this.props.maxValues) { return; } @@ -83,7 +79,7 @@ export default class MultiSelect extends React.Component { this.refs.select.focus(); } - onInput(input) { + onInput = (input) => { if (input === '') { this.refs.list.setSelected(-1); } else { @@ -94,7 +90,7 @@ export default class MultiSelect extends React.Component { this.props.handleInput(input); } - handleEnterPress(e) { + handleEnterPress = (e) => { switch (e.keyCode) { case KeyCodes.ENTER: if (this.selected == null) { @@ -106,7 +102,7 @@ export default class MultiSelect extends React.Component { } } - onChange(values) { + onChange = (values) => { if (values.length < this.props.values.length) { this.props.handleDelete(values); }