Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(taginput): selection with autocomplete on non string items #889

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/oruga/src/components/taginput/Taginput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ const props = defineProps({
},
/** Function to validate the value of the item before adding */
beforeAdding: {
type: Function as PropType<(value: string) => boolean>,
type: Function as PropType<(value: T | string) => boolean>,
default: () => true,
},
/** Function to create a new item to push into v-model (items) */
createItem: {
type: Function as PropType<(value: string) => T>,
default: (item: string) => item,
type: Function as PropType<(value: T | string) => T>,
default: (item: T | string) => item,
},
/** Makes the component check if list reached scroll start or end and emit scroll events. */
checkScroll: {
Expand Down Expand Up @@ -340,8 +340,8 @@ function getNormalizedItemText(item: T): string {
function addItem(item?: T | string): void {
item = item || newItem.value.trim();

if (item && typeof item === "string") {
if (!props.allowAutocomplete) {
if (item) {
if (typeof item === "string") {
const reg = separatorsAsRegExp.value;
if (reg && item.match(reg)) {
item.split(reg)
Expand Down Expand Up @@ -536,7 +536,7 @@ defineExpose({ focus: setFocus });
@keydown="onKeydown"
@compositionstart="isComposing = true"
@compositionend="isComposing = false"
@select="onSelect($event)"
@select="onSelect"
@scroll-start="$emit('scroll-start')"
@scroll-end="$emit('scroll-end')"
@icon-click="$emit('icon-click', $event)"
Expand Down