Skip to content

Commit

Permalink
pkp/pkp-lib#10624 Remove autosuggest props in api
Browse files Browse the repository at this point in the history
  • Loading branch information
blesildaramirez committed Nov 27, 2024
1 parent dd1875d commit aefcb78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 43 deletions.
22 changes: 10 additions & 12 deletions src/components/Form/fields/FieldBaseAutosuggest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ import Tooltip from '@/components/Tooltip/Tooltip.vue';
import HelpButton from '@/components/HelpButton/HelpButton.vue';
import FieldError from '@/components/Form/FieldError.vue';
import MultilingualProgress from '@/components/MultilingualProgress/MultilingualProgress.vue';
import {useAutosuggest} from '@/composables/useAutosuggest';
import ajaxError from '@/mixins/ajaxError';
import debounce from 'debounce';
Expand Down Expand Up @@ -269,17 +268,16 @@ export default {
return direction === 'rtl';
},
autoSuggestProps() {
const {autoSuggestProps} = useAutosuggest(
this.inputProps,
this.autosuggestId,
this.suggestions,
this.selectedLabel,
this.currentValue,
this.currentSelected,
this.isDisabled,
this.deselectLabel,
);
return autoSuggestProps;
return {
id: this.autosuggestId,
inputProps: this.inputProps,
suggestions: this.suggestions,
selectedLabel: this.selectedLabel,
currentValue: this.currentValue,
currentSelected: this.currentSelected,
isDisabled: this.isDisabled,
deselectLabel: this.deselectLabel,
};
},
},
watch: {
Expand Down
32 changes: 1 addition & 31 deletions src/composables/useAutosuggest.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
import {ref, inject} from 'vue';

export function useAutosuggest(
_inputProps = {},
_id = '',
_suggestions = [],
_selectedLabel = '',
_currentValue = '',
_currentSelected = [],
_isDisabled = false,
_deselectLabel = '',
) {
export function useAutosuggest() {
const allowCustom = inject('allowCustom', false);
const localInputValue = ref('');
const isFocused = ref(false);

const inputProps = ref(_inputProps);
const id = ref(_id);
const suggestions = ref(_suggestions);
const selectedLabel = ref(_selectedLabel);
const currentValue = ref(_currentValue);
const currentSelected = ref(_currentSelected);
const isDisabled = ref(_isDisabled);
const deselectLabel = ref(_deselectLabel);

function handleChange(event, emit) {
localInputValue.value = event.target.value.trim();
emit('update:inputValue', localInputValue.value);
Expand All @@ -38,24 +20,12 @@ export function useAutosuggest(
emit('update:isFocused', isFocused.value);
}

const autoSuggestProps = {
inputProps: inputProps.value,
id: id.value,
suggestions: suggestions.value,
selectedLabel: selectedLabel.value,
currentValue: currentValue.value,
currentSelected: currentSelected.value,
isDisabled: isDisabled.value,
deselectLabel: deselectLabel.value,
};

return {
allowCustom,
localInputValue,
isFocused,
handleChange,
handleFocus,
handleBlur,
autoSuggestProps,
};
}

0 comments on commit aefcb78

Please sign in to comment.