Skip to content

Commit

Permalink
Remove user from list when selected in DM modal (mattermost#5884)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilander authored and coreyhulen committed Mar 29, 2017
1 parent 793c0cc commit 5113067
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 13 additions & 1 deletion components/multiselect/multiselect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export default class MultiSelect extends React.Component {
}

render() {
const options = this.props.options;
const options = Object.assign([], this.props.options);
const values = this.props.values;

let numRemainingText;
if (this.props.numRemainingText) {
Expand Down Expand Up @@ -142,6 +143,17 @@ export default class MultiSelect extends React.Component {
);
}

const valueMap = {};
for (let i = 0; i < values.length; i++) {
valueMap[values[i].id] = true;
}

for (let i = options.length - 1; i >= 0; i--) {
if (valueMap[options[i].id]) {
options.splice(i, 1);
}
}

if (options && options.length > this.props.perPage) {
const pageStart = this.state.page * this.props.perPage;
const pageEnd = pageStart + this.props.perPage;
Expand Down
5 changes: 4 additions & 1 deletion components/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,10 @@ export default class Sidebar extends React.Component {
<li key='more'>
<a
href='#'
onClick={() => this.showMoreDirectChannelsModal()}
onClick={(e) => {
e.preventDefault();
this.showMoreDirectChannelsModal();
}}
>
<FormattedMessage
id='sidebar.moreElips'
Expand Down

0 comments on commit 5113067

Please sign in to comment.