mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Remove onInput call in input handler (#1819)
This was implemented by me to prevent seemingly empty fields, which however still contain some HTML (e.g. <div></div>) and thus will trigger in the templates. However it only worked in very limited cases, maybe we could solve this better by indicating whether a field has content somehow.
This commit is contained in:
parent
2be1f4c56d
commit
b8eabfd622
1 changed files with 0 additions and 14 deletions
|
@ -61,21 +61,8 @@ function useInputHandler(): [InputHandlerAPI, SetupInputHandlerAction] {
|
||||||
insertText.clear();
|
insertText.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInput(this: HTMLElement, event: InputEvent): void {
|
|
||||||
// prevent unwanted <div> from being left behind when clearing field contents
|
|
||||||
if (
|
|
||||||
!event.data &&
|
|
||||||
this.children.length === 1 &&
|
|
||||||
this.children.item(0) instanceof HTMLDivElement &&
|
|
||||||
/^\n?$/.test(this.innerText)
|
|
||||||
) {
|
|
||||||
this.innerHTML = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupHandler(element: HTMLElement): { destroy(): void } {
|
function setupHandler(element: HTMLElement): { destroy(): void } {
|
||||||
const beforeInputOff = on(element, "beforeinput", onBeforeInput);
|
const beforeInputOff = on(element, "beforeinput", onBeforeInput);
|
||||||
const inputOff = on(element, "input" as "beforeinput", onInput);
|
|
||||||
|
|
||||||
const blurOff = on(element, "blur", clearInsertText);
|
const blurOff = on(element, "blur", clearInsertText);
|
||||||
const pointerDownOff = on(element, "pointerdown", clearInsertText);
|
const pointerDownOff = on(element, "pointerdown", clearInsertText);
|
||||||
|
@ -84,7 +71,6 @@ function useInputHandler(): [InputHandlerAPI, SetupInputHandlerAction] {
|
||||||
return {
|
return {
|
||||||
destroy() {
|
destroy() {
|
||||||
beforeInputOff();
|
beforeInputOff();
|
||||||
inputOff();
|
|
||||||
blurOff();
|
blurOff();
|
||||||
pointerDownOff();
|
pointerDownOff();
|
||||||
selectionChangeOff();
|
selectionChangeOff();
|
||||||
|
|
Loading…
Reference in a new issue