mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Disable add-on buttons when no field is focused by default (#2532)
This commit is contained in:
parent
51dc5860bd
commit
3a32e4b1bd
1 changed files with 11 additions and 0 deletions
|
@ -362,6 +362,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
$closeHTMLTags = closeTags;
|
$closeHTMLTags = closeTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/Disable add-on buttons that do not have the `perm` class
|
||||||
|
*/
|
||||||
|
function setAddonButtonsDisabled(disabled: boolean): void {
|
||||||
|
document.querySelectorAll("button.linkb:not(.perm)").forEach((button) => {
|
||||||
|
(button as HTMLButtonElement).disabled = disabled;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
import { wrapInternal } from "@tslib/wrap";
|
import { wrapInternal } from "@tslib/wrap";
|
||||||
import Shortcut from "components/Shortcut.svelte";
|
import Shortcut from "components/Shortcut.svelte";
|
||||||
|
|
||||||
|
@ -467,10 +476,12 @@ the AddCards dialog) should be implemented in the user of this component.
|
||||||
api={fields[index]}
|
api={fields[index]}
|
||||||
on:focusin={() => {
|
on:focusin={() => {
|
||||||
$focusedField = fields[index];
|
$focusedField = fields[index];
|
||||||
|
setAddonButtonsDisabled(false);
|
||||||
bridgeCommand(`focus:${index}`);
|
bridgeCommand(`focus:${index}`);
|
||||||
}}
|
}}
|
||||||
on:focusout={() => {
|
on:focusout={() => {
|
||||||
$focusedField = null;
|
$focusedField = null;
|
||||||
|
setAddonButtonsDisabled(true);
|
||||||
bridgeCommand(
|
bridgeCommand(
|
||||||
`blur:${index}:${getNoteId()}:${transformContentBeforeSave(
|
`blur:${index}:${getNoteId()}:${transformContentBeforeSave(
|
||||||
get(content),
|
get(content),
|
||||||
|
|
Loading…
Reference in a new issue