mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix autocomplete dropdown
+ find a different solution for making tags and tag inputs same size
This commit is contained in:
parent
3dff89fda5
commit
201773e7c6
3 changed files with 58 additions and 63 deletions
|
@ -133,6 +133,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
$with-disabled: false,
|
$with-disabled: false,
|
||||||
$with-hover: false
|
$with-hover: false
|
||||||
);
|
);
|
||||||
|
|
||||||
@include button.btn-night(
|
@include button.btn-night(
|
||||||
$with-active: false,
|
$with-active: false,
|
||||||
$with-disabled: false,
|
$with-disabled: false,
|
||||||
|
|
|
@ -374,7 +374,23 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#each tags as tag, index (tag.id)}
|
{#each tags as tag, index (tag.id)}
|
||||||
<div class="pb-1">
|
<div class="position-relative pb-1" class:hide-tag={index === active}>
|
||||||
|
<Tag
|
||||||
|
name={tag.name}
|
||||||
|
bind:flash={tag.flash}
|
||||||
|
bind:selected={tag.selected}
|
||||||
|
on:tagedit={() => {
|
||||||
|
active = index;
|
||||||
|
deselect();
|
||||||
|
}}
|
||||||
|
on:tagselect={() => select(index)}
|
||||||
|
on:tagrange={() => selectRange(index)}
|
||||||
|
on:tagdelete={() => {
|
||||||
|
deleteTagAt(index);
|
||||||
|
saveTags();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
{#if index === active}
|
{#if index === active}
|
||||||
<WithAutocomplete
|
<WithAutocomplete
|
||||||
class="d-flex flex-column-reverse dropup"
|
class="d-flex flex-column-reverse dropup"
|
||||||
|
@ -387,6 +403,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
>
|
>
|
||||||
<TagInput
|
<TagInput
|
||||||
id={tag.id}
|
id={tag.id}
|
||||||
|
class="position-absolute top-0 start-0"
|
||||||
bind:name={activeName}
|
bind:name={activeName}
|
||||||
bind:input={activeInput}
|
bind:input={activeInput}
|
||||||
on:focus={() => {
|
on:focus={() => {
|
||||||
|
@ -414,22 +431,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</WithAutocomplete>
|
</WithAutocomplete>
|
||||||
{:else}
|
|
||||||
<Tag
|
|
||||||
name={tag.name}
|
|
||||||
bind:flash={tag.flash}
|
|
||||||
bind:selected={tag.selected}
|
|
||||||
on:tagedit={() => {
|
|
||||||
active = index;
|
|
||||||
deselect();
|
|
||||||
}}
|
|
||||||
on:tagselect={() => select(index)}
|
|
||||||
on:tagrange={() => selectRange(index)}
|
|
||||||
on:tagdelete={() => {
|
|
||||||
deleteTagAt(index);
|
|
||||||
saveTags();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -445,4 +446,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
.tag-spacer {
|
.tag-spacer {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hide-tag :global(.tag) {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -3,10 +3,13 @@ Copyright: Ankitects Pty Ltd and contributors
|
||||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import { onMount, onDestroy, createEventDispatcher, tick } from "svelte";
|
import { onMount, createEventDispatcher, tick } from "svelte";
|
||||||
import { normalizeTagname } from "./tags";
|
import { normalizeTagname } from "./tags";
|
||||||
|
|
||||||
export let id: string | undefined = undefined;
|
export let id: string | undefined = undefined;
|
||||||
|
let className: string = "";
|
||||||
|
export { className as class };
|
||||||
|
|
||||||
export let name: string;
|
export let name: string;
|
||||||
export let input: HTMLInputElement;
|
export let input: HTMLInputElement;
|
||||||
|
|
||||||
|
@ -170,54 +173,40 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
onMount(() => input.focus());
|
onMount(() => input.focus());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="ps-2 pe-1" data-value={name}>
|
<input
|
||||||
<input
|
{id}
|
||||||
{id}
|
class={className}
|
||||||
bind:this={input}
|
bind:this={input}
|
||||||
bind:value={name}
|
bind:value={name}
|
||||||
type="text"
|
type="text"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
size="1"
|
size="1"
|
||||||
on:focus
|
on:focus
|
||||||
on:blur={onBlur}
|
on:blur={onBlur}
|
||||||
on:keydown={onKeydown}
|
on:keydown={onKeydown}
|
||||||
on:keydown
|
on:keydown
|
||||||
on:keyup
|
on:keyup
|
||||||
on:input
|
on:input
|
||||||
on:paste={onPaste}
|
on:paste={onPaste}
|
||||||
/>
|
/>
|
||||||
</label>
|
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
label {
|
input {
|
||||||
display: inline-grid;
|
padding-left: 9.5px;
|
||||||
|
padding-bottom: 5.5px;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
&::after,
|
color: var(--text-fg);
|
||||||
input {
|
background: none;
|
||||||
color: var(--text-fg);
|
resize: none;
|
||||||
background: none;
|
appearance: none;
|
||||||
resize: none;
|
font: inherit;
|
||||||
appearance: none;
|
/* TODO we need something like --base-font-size for buttons' 13px */
|
||||||
width: auto;
|
font-size: 13px;
|
||||||
grid-area: 1 / 1;
|
outline: none;
|
||||||
font: inherit;
|
border: none;
|
||||||
/* TODO we need something like --base-font-size for buttons' 13px */
|
margin: 0;
|
||||||
font-size: 13px;
|
|
||||||
outline: none;
|
|
||||||
border: none;
|
|
||||||
margin: 0;
|
|
||||||
/* adjust so deleting all tags does not cause a reflow */
|
|
||||||
padding: 3.2px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
/* 7 spaces to minimize reflow on clicking tag */
|
|
||||||
content: attr(data-value) " ";
|
|
||||||
visibility: hidden;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
position: relative;
|
|
||||||
top: -2rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue