Fix broken tag editor in Svelte 5 (#3488)

* Fix temporary disappearance of a tag

https://forums.ankiweb.net/t/anki-24-10-beta/49989/47

* Fix incorrect behavior after tag deletion

* Fix tag addition/selection buttons becoming invisible

Once tags were selected, subsequent deselection or selection did not
mount 'TagAddButton' or 'TagsSelectedButton' components.
This commit is contained in:
Hikaru Y. 2024-10-11 22:21:00 +09:00 committed by GitHub
parent 931e1d80f2
commit e79060487b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 7 deletions

View file

@ -43,9 +43,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
>
<TagDeleteBadge
class={hoverClass}
on:click={() => {
on:click={(evt) => {
if (!selectMode) {
deleteTag();
evt.stopPropagation();
}
}}
/>

View file

@ -76,6 +76,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
* Choose as accepted suggestion
*/
async function chooseSelected() {
if (!suggestionsItems.length) {
return;
}
active = true;
dispatch("choose", { chosen: suggestionsItems[selected ?? -1] });
@ -129,7 +133,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
keepOnKeyup
show={$show}
preferredPlacement="top"
portalTarget={document.body}
let:asReference
on:close={() => show.set(false)}
>

View file

@ -17,11 +17,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
bind:offsetHeight={badgeHeight}
on:mousedown|preventDefault
>
{#if tagsSelected}
<TagsSelectedButton on:tagselectall on:tagcopy on:tagdelete />
{:else}
<TagAddButton on:tagappend {keyCombination} />
{/if}
{#key tagsSelected}
{#if tagsSelected}
<TagsSelectedButton on:tagselectall on:tagcopy on:tagdelete />
{:else}
<TagAddButton on:tagappend {keyCombination} />
{/if}
{/key}
</div>
<style lang="scss">