mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-02 22:03:48 +08:00
7a8954ee65
User search input blur would trigger the submission of the search filters which would cause strange thing where you'd click on a search filtered user which would blur the input hence submit, but the user would think they've clicked the user and the page would reload but the input had not updated at that point. Related to #2863
25 lines
669 B
JavaScript
25 lines
669 B
JavaScript
import {onChildEvent} from "../services/dom";
|
|
|
|
class UserSelect {
|
|
|
|
setup() {
|
|
this.input = this.$refs.input;
|
|
this.userInfoContainer = this.$refs.userInfo;
|
|
|
|
this.hide = this.$el.components.dropdown.hide;
|
|
|
|
onChildEvent(this.$el, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
|
|
}
|
|
|
|
selectUser(event, userEl) {
|
|
event.preventDefault();
|
|
const id = userEl.getAttribute('data-id');
|
|
this.input.value = id;
|
|
this.userInfoContainer.innerHTML = userEl.innerHTML;
|
|
this.input.dispatchEvent(new Event('change', {bubbles: true}));
|
|
this.hide();
|
|
}
|
|
|
|
}
|
|
|
|
export default UserSelect; |