mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Fix autocomplete showing on arrow keys and height resize on no tags
This commit is contained in:
parent
a29d21f4fd
commit
85567fddd9
1 changed files with 30 additions and 23 deletions
|
@ -231,15 +231,24 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
activeAfterBlur = null;
|
||||
}
|
||||
|
||||
function printableKey(event: KeyboardEvent): boolean {
|
||||
return (
|
||||
(event.location === KeyboardEvent.DOM_KEY_LOCATION_STANDARD ||
|
||||
event.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) &&
|
||||
!event.code.startsWith("Arrow")
|
||||
);
|
||||
}
|
||||
|
||||
function update(event: KeyboardEvent, autocomplete: any): void {
|
||||
const visible = autocomplete.isVisible();
|
||||
const printable = printableKey(event);
|
||||
|
||||
if (
|
||||
!visible &&
|
||||
(event.location === KeyboardEvent.DOM_KEY_LOCATION_STANDARD ||
|
||||
event.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD)
|
||||
) {
|
||||
if (!visible) {
|
||||
if (printable) {
|
||||
autocomplete.show();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (event.code) {
|
||||
|
@ -269,7 +278,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
break;
|
||||
|
||||
default:
|
||||
if (event.code.startsWith("Arrow")) {
|
||||
if (!printable) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -280,11 +289,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
</script>
|
||||
|
||||
<StickyBottom>
|
||||
<div class="row-gap">
|
||||
<ButtonToolbar class="dropup d-flex flex-wrap align-items-center" {size}>
|
||||
<div class="pb-1">
|
||||
<AddTagBadge on:click={appendEmptyTag} />
|
||||
</div>
|
||||
|
||||
{#each tags as tag, index (tag.id)}
|
||||
<div class="pb-1">
|
||||
{#if index === active}
|
||||
<WithAutocomplete
|
||||
class="d-flex flex-column-reverse"
|
||||
|
@ -340,6 +351,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<div
|
||||
|
@ -349,14 +361,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
{active}
|
||||
{activeAfterBlur}
|
||||
</ButtonToolbar>
|
||||
</div>
|
||||
</StickyBottom>
|
||||
|
||||
<style lang="scss">
|
||||
.row-gap > :global(.d-flex > *) {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.tag-spacer {
|
||||
cursor: text;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue