mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-17 17:10:03 +01:00
Revert back the event delegation suggestion because in this case we search the closest descendant, not the closest ancestor.
This commit is contained in:
parent
4f50d0de3e
commit
76f434b039
1 changed files with 13 additions and 9 deletions
|
@ -2,7 +2,6 @@ import { HistorySuggestion } from '../../utils/suggestions';
|
|||
import { InputHistory } from './history';
|
||||
import { HistoryStore } from './store';
|
||||
import { AutocompletableInput } from '../input';
|
||||
import { delegate } from 'utils/events';
|
||||
|
||||
/**
|
||||
* Stores a set of histories identified by their unique IDs.
|
||||
|
@ -39,15 +38,20 @@ export function listen() {
|
|||
histories.load(input.historyId);
|
||||
});
|
||||
|
||||
delegate(document, 'submit', {
|
||||
'[data-autocomplete-history-id]'(_event, target) {
|
||||
const input = AutocompletableInput.fromElement(target);
|
||||
if (!input || !input.hasHistory()) {
|
||||
return;
|
||||
}
|
||||
document.addEventListener('submit', event => {
|
||||
if (!(event.target instanceof HTMLFormElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
histories.load(input.historyId).write(input.snapshot.trimmedValue);
|
||||
},
|
||||
const input = [...event.target.elements]
|
||||
.map(elem => AutocompletableInput.fromElement(elem))
|
||||
.find(it => it !== null && it.hasHistory());
|
||||
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
|
||||
histories.load(input.historyId).write(input.snapshot.trimmedValue);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue