Fix field description not toggled properly (#1919)

It appears that a variable bound to the `innerHTML` property of
a contenteditable element is only updated when `input` event fires on
the element, and not when changes are made to the DOM programmatically.
This commit is contained in:
Hikaru Y 2022-06-21 09:12:00 +09:00 committed by GitHub
parent 3969487e77
commit bc5633e070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -39,14 +39,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
const description = getContext<Readable<string>>(descriptionKey);
$: descriptionCSSValue = `"${$description}"`;
let innerHTML = "";
$: empty = ["", "<br>"].includes(innerHTML);
export let content: Writable<string>;
</script>
<anki-editable
class:empty
class:empty={!$content}
contenteditable="true"
bind:innerHTML
use:resolve
use:setupFocusHandling
use:preventBuiltinShortcuts

View file

@ -148,6 +148,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
mirrors: [mirror],
inputHandlers: [setupInputHandler, setupGlobalInputHandler],
api: api.editable,
content,
},
context: allContexts,
});