mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
Make automatic deselect when leaving tag editor
This commit is contained in:
parent
080b80e3ce
commit
376f543680
2 changed files with 21 additions and 2 deletions
|
|
@ -81,6 +81,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
class={`btn-toolbar container wrap-variable ${className}`}
|
||||
{style}
|
||||
role="toolbar"
|
||||
on:focusout
|
||||
>
|
||||
<slot />
|
||||
{#each $dynamicItems as item}
|
||||
|
|
|
|||
|
|
@ -278,10 +278,25 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
autocomplete.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function deselect() {
|
||||
tags = tags.map((tag: TagType): TagType => ({ ...tag, selected: false }));
|
||||
}
|
||||
|
||||
function deselectIfLeave(event: FocusEvent) {
|
||||
const toolbar = event.currentTarget as HTMLDivElement;
|
||||
if (!toolbar.contains(event.relatedTarget as Element)) {
|
||||
deselect();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<StickyBottom>
|
||||
<ButtonToolbar class="dropup d-flex flex-wrap align-items-center" {size}>
|
||||
<ButtonToolbar
|
||||
class="dropup d-flex flex-wrap align-items-center"
|
||||
{size}
|
||||
on:focusout={deselectIfLeave}
|
||||
>
|
||||
<div class="pb-1">
|
||||
<AddTagBadge on:click={appendEmptyTag} />
|
||||
</div>
|
||||
|
|
@ -338,7 +353,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
name={tag.name}
|
||||
bind:flash={tag.flash}
|
||||
bind:selected={tag.selected}
|
||||
on:tagedit={() => (active = index)}
|
||||
on:tagedit={() => {
|
||||
active = index;
|
||||
deselect();
|
||||
}}
|
||||
on:tagrange={console.log}
|
||||
on:tagdelete={() => {
|
||||
deleteTagAt(index);
|
||||
|
|
|
|||
Loading…
Reference in a new issue