Skip to content

Commit

Permalink
feat(ui): make filter dropdown be positioned below the input caret
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosPaunovic committed Feb 27, 2025
1 parent 9bab2d2 commit c8bb5bc
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ui/src/components/filter/KestraFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
:show-arrow="false"
fit-input-width
:popper-class="!!props.searchCallback ? 'd-none' : 'filters-select'"
:popper-options="{
modifiers: [
{
name: 'offset',
options: {
offset: [dropdownOffset, 12],
},
},
],
}"
@change="(value) => changeCallback(value)"
@keyup="(e) => handleInputChange(e.key)"
@keyup.enter="() => handleEnterKey(select?.hoverOption?.value)"
Expand Down Expand Up @@ -310,7 +320,9 @@
};
const handleClear = () => {
currentFilters.value = currentFilters.value.filter((item) => item.persistent);
currentFilters.value = currentFilters.value.filter(
(item) => item.persistent,
);
triggerSearch();
};
Expand Down Expand Up @@ -384,6 +396,10 @@
updateHoveringIndex(0);
};
let dropdownOffset = ref(0);
const calculateDropdownOffset = (left: number = 0, halfWidth: number = 0) => {
return left > halfWidth ? Math.abs(halfWidth - left) : -(halfWidth - left);
};
const dropdownToggleCallback = (visible) => {
if (!visible) {
dropdowns.value = {...INITIAL_DROPDOWNS};
Expand All @@ -394,6 +410,12 @@
if (currentFilters.value?.at(-1)?.value?.length === 0)
currentFilters.value.pop();
} else {
const {selectRef, inputRef} = select.value || {};
dropdownOffset.value = calculateDropdownOffset(
inputRef?.offsetLeft,
selectRef?.offsetWidth / 2,
);
updateHoveringIndex(0);
}
};
Expand Down

0 comments on commit c8bb5bc

Please sign in to comment.