Updated tiles logics

This commit is contained in:
2024-07-11 19:52:33 +02:00
parent 90046613ca
commit e72a3a9f45
9 changed files with 143 additions and 105 deletions

View File

@ -4,7 +4,8 @@
<span>{{ chip }}</span>
<i class="cursor-pointer text-white font-light font-default not-italic hover:text-gray-50" @click="deleteChip(i)">X</i>
</div>
<input class="outline-none border-none max-w-[250px] p-1 m-1 text-white" v-model="currentInput" @keyup.enter="saveChip" @keydown.delete="backspaceDelete" />
<!-- Use keypress event and prevent modifier -->
<input class="outline-none border-none max-w-[250px] p-1 m-1 text-white" v-model="currentInput" @keypress.enter.prevent="saveChip" @keydown.delete="backspaceDelete" />
</div>
</template>
@ -15,7 +16,9 @@ const modelValue = defineModel('modelValue', { type: Array, default: () => [] })
const currentInput = ref('')
const saveChip = () => {
const saveChip = (event) => {
// Prevent form submission explicitly if needed
event.preventDefault()
if (currentInput.value.trim() && !modelValue.value.includes(currentInput.value)) {
modelValue.value = [...modelValue.value, currentInput.value]
currentInput.value = ''
@ -31,4 +34,4 @@ const backspaceDelete = (event) => {
modelValue.value = modelValue.value.slice(0, -1)
}
}
</script>
</script>