fix(form_builder): Use locale-aware sorting and search for fieldtypes (#23454)

* fix(form_builder): Use locale-aware string sort and search for DocFields

* fix(form_builder): Fix CSS cursor for DocField autocomplete
This commit is contained in:
Corentin Flr 2023-12-01 17:09:52 +01:00 committed by GitHub
parent 668b3c0026
commit 6f36c0fa0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,7 @@
<div class="combo-box-items">
<ComboboxOption
as="template"
v-for="(field, i) in filteredOptions"
v-for="(field, i) in sortedOptions"
:key="i"
:value="field"
v-slot="{ active }"
@ -85,11 +85,16 @@ const selectedValue = computed({
});
const filteredOptions = computed(() => {
return query.value
? props.options.filter((option) => {
return option.label.toLowerCase().includes(query.value.toLowerCase());
})
: props.options;
if (!query.value) return props.options;
return props.options.filter((option) => {
return option.label.toLocaleLowerCase().includes(query.value.toLocaleLowerCase());
});
});
const sortedOptions = computed(() => {
return filteredOptions.value.sort((a, b) => {
return a.label.localeCompare(b.label);
});
});
function clear_search() {
@ -126,6 +131,8 @@ watch(showOptions, (val) => {
border-radius: var(--border-radius-sm);
padding: 6px 10px;
width: 100%;
cursor: pointer;
user-select: none;
&:hover,
&.active {