Skip to content

Commit

Permalink
#923: review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lehju committed Jun 3, 2024
1 parent 990c772 commit 28cb0f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div id="top">
<v-autocomplete
ref="autocompletion"
v-model="selectedUsers"
:aria-required="isRequired()"
:auto-select-first="!screenreaderMode"
Expand Down Expand Up @@ -175,12 +176,14 @@ export default defineComponent({
*/
const locked = ref(false);
const errorMessage = ref("");
const lastSearch = ref("");
const currentSearch = ref("");
const a11YNotificationEnabled = useAccessibility().a11YNotificationEnabled;
const screenreaderMode = computed(() => a11YNotificationEnabled());
const autocompletion = ref();
watch(searchText, (newValue) => {
searchUsersBySearchString(newValue);
});
Expand Down Expand Up @@ -229,22 +232,21 @@ export default defineComponent({
(it) => it.lhmObjectId !== user.lhmObjectId
);
change();
autocompletion.value.focus();
};
const mucatarUrl = (uid: string) => mucatarURL(uid);
const searchUsersBySearchString = (searchString: string) => {
if (!searchString || searchString.length < 3) return;
if (lastSearch.value === searchString.slice(0, 3)) return;
lastSearch.value = searchString.slice(0, 3);
currentSearch.value = searchString.slice(0, 3);
isLoading.value = true;
callSearchUser(lastSearch.value, ldapGroups)
callSearchUser(currentSearch.value, ldapGroups)
.then((users) => {
if (lastSearch.value === searchText.value.slice(0, 3)) {
if (currentSearch.value === searchText.value.slice(0, 3)) {
items.value = users;
}
errorMessage.value = "";
Expand All @@ -265,7 +267,7 @@ export default defineComponent({
};
const resetInput = (): void => {
lastSearch.value = "";
currentSearch.value = "";
searchText.value = "";
items.value = [];
};
Expand All @@ -285,6 +287,7 @@ export default defineComponent({
}
return {
autocompletion,
screenreaderMode,
resetInput,
change,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
v-model="selectedUser"
:aria-required="isRequired()"
:auto-select-first="!screenreaderMode"
:disabled="screenreaderMode && !!selectedUser"
:filter="filterUsers"
:items="entries()"
:label="label"
Expand Down Expand Up @@ -146,7 +145,7 @@ export default defineComponent({
*/
const locked = ref(false);
const errorMessage = ref("");
const lastSearch = ref("");
const currentSearch = ref("");
const noDataText = ref<string>("Tippen, um Suche zu starten");
Expand Down Expand Up @@ -206,17 +205,15 @@ export default defineComponent({
const searchUsersBySearchString = (searchString: string) => {
if (!searchString || searchString.length < 3) return;
if (lastSearch.value === searchString.slice(0, 3)) return;
lastSearch.value = searchString.slice(0, 3);
currentSearch.value = searchString.slice(0, 3);
isLoading.value = true;
noDataText.value = "Benutzer werden gesucht...";
callSearchUser(lastSearch.value, ldapGroups)
callSearchUser(currentSearch.value, ldapGroups)
.then((users) => {
if (lastSearch.value === searchText.value.slice(0, 3)) {
if (currentSearch.value === searchText.value.slice(0, 3)) {
items.value = users;
}
errorMessage.value = "";
Expand All @@ -231,7 +228,7 @@ export default defineComponent({
};
const resetInput = (): void => {
lastSearch.value = "";
currentSearch.value = "";
searchText.value = "";
items.value = [];
};
Expand Down

0 comments on commit 28cb0f3

Please sign in to comment.