Skip to content

Commit

Permalink
Merge pull request #6552 from getkirby/fix/6468-tags-input-maxed-drop…
Browse files Browse the repository at this point in the history
…down-opens

Tags input: don't open dropdown when max reached
  • Loading branch information
bastianallgeier authored Jul 22, 2024
2 parents 4756897 + b309b72 commit f45f7c4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions panel/src/components/Forms/Input/TagsInput.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="k-tags-input">
<div :data-can-add="canAdd" class="k-tags-input">
<k-tags
ref="tags"
v-bind="$props"
Expand All @@ -8,7 +8,7 @@
@click.native.stop="$refs.toggle?.$el?.click()"
>
<k-button
v-if="!max || value.length < max"
v-if="canAdd"
:id="id"
ref="toggle"
:autofocus="autofocus"
Expand Down Expand Up @@ -75,6 +75,9 @@ export default {
};
},
computed: {
canAdd() {
return !this.max || this.value.length < this.max;
},
creatableOptions() {
// tags should be unique, so when creating,
// only show options that are not already selected
Expand Down Expand Up @@ -155,7 +158,9 @@ export default {
this.$refs.replace.open();
},
focus() {
this.$refs.create.open();
if (this.canAdd) {
this.$refs.create.open();
}
},
isAllowed(tag) {
if (typeof tag !== "object" || tag.value.trim().length === 0) {
Expand Down Expand Up @@ -223,6 +228,8 @@ export default {
<style>
.k-tags-input {
padding: var(--tags-gap);
}
.k-tags-input[data-can-add="true"] {
cursor: pointer;
}
Expand Down

0 comments on commit f45f7c4

Please sign in to comment.