Skip to content

Commit 9d5f0fd

Browse files
committed
v1.0.2
1 parent 147cf25 commit 9d5f0fd

File tree

8 files changed

+36
-32
lines changed

8 files changed

+36
-32
lines changed

docs/api/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="keywords" content="bootstrap tag, tag input, bootstrap input">
66
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
77
<title>use-bootstrap-tag | Tag input for Bootstrap 5</title>
8-
<script type="module" crossorigin="" src="/assets/index-98453bde.js"></script>
8+
<script type="module" crossorigin="" src="/assets/index-17a59a0c.js"></script>
99
<link rel="stylesheet" href="/assets/index-088aae3b.css">
1010
</head>
1111

docs/assets/index-088aae3b.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/customize/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="keywords" content="bootstrap tag, tag input, bootstrap input">
66
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
77
<title>use-bootstrap-tag | Tag input for Bootstrap 5</title>
8-
<script type="module" crossorigin="" src="/assets/index-98453bde.js"></script>
8+
<script type="module" crossorigin="" src="/assets/index-17a59a0c.js"></script>
99
<link rel="stylesheet" href="/assets/index-088aae3b.css">
1010
</head>
1111

@@ -68,7 +68,7 @@
6868
// 9. Add additional custom code here</code></pre> <p>By default, use-bootstrap-tag inherits its style from default bootstrap
6969
style, so anything you change in bootstrap automatically changes
7070
use-bootstrap-tag style as well. Read more about customize bootstrap styles
71-
at <a href="https://getbootstrap.com/docs/5.3/customize/sass/" target="_blank">https://getbootstrap.com/docs/5.3/customize/sass/</a>.</p> <div class="d-flex justify-content-between gap-3 mt-4"><a href="/api" class="btn btn-link link-body-emphasis text-decoration-none border d-inline-flex flex-column align-items-start w-50"><span class="text-body-secondary small">Previous page</span>
71+
at <a class="text-break" href="https://getbootstrap.com/docs/5.3/customize/sass/" target="_blank">https://getbootstrap.com/docs/5.3/customize/sass/</a>.</p> <div class="d-flex justify-content-between gap-3 mt-4"><a href="/api" class="btn btn-link link-body-emphasis text-decoration-none border d-inline-flex flex-column align-items-start w-50"><span class="text-body-secondary small">Previous page</span>
7272
API</a></div></div></div></div></div>
7373

7474

docs/demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="keywords" content="bootstrap tag, tag input, bootstrap input">
66
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
77
<title>use-bootstrap-tag | Tag input for Bootstrap 5</title>
8-
<script type="module" crossorigin="" src="/assets/index-98453bde.js"></script>
8+
<script type="module" crossorigin="" src="/assets/index-17a59a0c.js"></script>
99
<link rel="stylesheet" href="/assets/index-088aae3b.css">
1010
</head>
1111

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="keywords" content="bootstrap tag, tag input, bootstrap input">
66
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
77
<title>use-bootstrap-tag | Tag input for Bootstrap 5</title>
8-
<script type="module" crossorigin="" src="/assets/index-98453bde.js"></script>
8+
<script type="module" crossorigin="" src="/assets/index-17a59a0c.js"></script>
99
<link rel="stylesheet" href="/assets/index-088aae3b.css">
1010
</head>
1111

docs/install/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="keywords" content="bootstrap tag, tag input, bootstrap input">
66
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
77
<title>use-bootstrap-tag | Tag input for Bootstrap 5</title>
8-
<script type="module" crossorigin="" src="/assets/index-98453bde.js"></script>
8+
<script type="module" crossorigin="" src="/assets/index-17a59a0c.js"></script>
99
<link rel="stylesheet" href="/assets/index-088aae3b.css">
1010
</head>
1111

src/lib/use-bootstrap-tag.svelte

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
$: if (textFocus) {
4646
textElement.focus()
4747
}
48+
$: if (tagActiveIndex >= 0) {
49+
getTagElement(tagActiveIndex + 1).focus()
50+
}
4851
4952
inputElement.classList.add(`${name}-target`)
5053
inputElement.tabIndex = -1
@@ -116,24 +119,22 @@
116119
}
117120
async function handleTagKeyup(e: KeyboardEvent) {
118121
if (e.key === keyBackspace || e.key === 'Delete') {
119-
handleRemove(+(e.target as HTMLButtonElement).dataset.index)
122+
const index = +(e.target as HTMLButtonElement).dataset.index
123+
handleRemove(index)
120124
await tick()
125+
tagActiveIndex = values.length === index ? index - 1 : index
121126
if (tagActiveIndex === -1) {
122127
textFocus = true
123128
}
124129
}
125130
}
126131
function handleExists(existingIndex: number[]) {
127132
existingIndex.forEach((index) => {
128-
const tag = root.querySelector<HTMLButtonElement>(
129-
`button:nth-child(${index + 1})`
130-
)
131-
if (tag) {
132-
tag.style.transform = 'scale(1.1)'
133-
setTimeout(() => {
134-
tag.style.transform = 'none'
135-
}, 150)
136-
}
133+
const tag = getTagElement(index + 1)
134+
tag.style.transform = 'scale(1.1)'
135+
setTimeout(() => {
136+
tag.style.transform = 'none'
137+
}, 150)
137138
})
138139
}
139140
function appendTag(force = false) {
@@ -178,6 +179,9 @@
178179
e.preventDefault() // prevent form submit
179180
}
180181
}
182+
function getTagElement(index: number) {
183+
return root.querySelector<HTMLButtonElement>(`button:nth-child(${index})`)
184+
}
181185
</script>
182186

183187
<div

0 commit comments

Comments
 (0)