mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-12 21:43: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
26 lines
530 B
JavaScript
26 lines
530 B
JavaScript
/**
|
|
* Submit on change
|
|
* Simply submits a parent form when this input is changed.
|
|
* @extends {Component}
|
|
*/
|
|
class SubmitOnChange {
|
|
|
|
setup() {
|
|
this.filter = this.$opts.filter;
|
|
|
|
this.$el.addEventListener('change', (event) => {
|
|
|
|
if (this.filter && !event.target.matches(this.filter)) {
|
|
return;
|
|
}
|
|
|
|
const form = this.$el.closest('form');
|
|
if (form) {
|
|
form.submit();
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
export default SubmitOnChange; |