Skip to content

Commit

Permalink
pkp/pkp-lib#10624 Allow custom value when selecting affiliation
Browse files Browse the repository at this point in the history
  • Loading branch information
blesildaramirez committed Dec 20, 2024
1 parent ccd51cd commit 5b28939
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/Form/fields/FieldRorAutosuggest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</template>

<script setup>
import {ref, watch, computed} from 'vue';
import {ref, watch, computed, provide} from 'vue';
import Autosuggest from './Autosuggest.vue';
import Icon from '@/components/Icon/Icon.vue';
import {useFetch} from '@/composables/useFetch';
Expand All @@ -70,6 +70,8 @@ const queryParams = computed(() => ({
query: inputValue.value,
}));
provide('allowCustom', true);
const autosuggestContainerId = generateId();
const {
Expand Down Expand Up @@ -127,6 +129,17 @@ function changeFocus(focused) {
}
function handleSelect(suggestion) {
if (!suggestion) {
if (!inputValue.value || !mappedSuggestions.value.length) {
return;
}
suggestion = {
value: inputValue.value,
label: inputValue.value,
};
}
if (!currentSelected.value.some((item) => item.value === suggestion.value)) {
currentSelected.value.push(suggestion);
}
Expand Down

0 comments on commit 5b28939

Please sign in to comment.