mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: command arrow up/down behaviour
This commit is contained in:
parent
c201b4d689
commit
62180b15e1
@ -878,20 +878,38 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
commandsElement.selectUp();
|
commandsElement.selectUp();
|
||||||
|
|
||||||
|
const container = document.getElementById('command-options-container');
|
||||||
const commandOptionButton = [
|
const commandOptionButton = [
|
||||||
...document.getElementsByClassName('selected-command-option-button')
|
...document.getElementsByClassName('selected-command-option-button')
|
||||||
]?.at(-1);
|
]?.at(-1);
|
||||||
commandOptionButton.scrollIntoView({ block: 'center' });
|
|
||||||
|
if (commandOptionButton && container) {
|
||||||
|
const elTop = commandOptionButton.offsetTop;
|
||||||
|
const elHeight = commandOptionButton.offsetHeight;
|
||||||
|
const containerHeight = container.clientHeight;
|
||||||
|
|
||||||
|
// Center the selected button in the container
|
||||||
|
container.scrollTop = elTop - containerHeight / 2 + elHeight / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandsContainerElement && e.key === 'ArrowDown') {
|
if (commandsContainerElement && e.key === 'ArrowDown') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
commandsElement.selectDown();
|
commandsElement.selectDown();
|
||||||
|
|
||||||
|
const container = document.getElementById('command-options-container');
|
||||||
const commandOptionButton = [
|
const commandOptionButton = [
|
||||||
...document.getElementsByClassName('selected-command-option-button')
|
...document.getElementsByClassName('selected-command-option-button')
|
||||||
]?.at(-1);
|
]?.at(-1);
|
||||||
commandOptionButton.scrollIntoView({ block: 'center' });
|
|
||||||
|
if (commandOptionButton && container) {
|
||||||
|
const elTop = commandOptionButton.offsetTop;
|
||||||
|
const elHeight = commandOptionButton.offsetHeight;
|
||||||
|
const containerHeight = container.clientHeight;
|
||||||
|
|
||||||
|
// Center the selected button in the container
|
||||||
|
container.scrollTop = elTop - containerHeight / 2 + elHeight / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandsContainerElement && e.key === 'Enter') {
|
if (commandsContainerElement && e.key === 'Enter') {
|
||||||
|
@ -170,10 +170,11 @@
|
|||||||
class="px-2 mb-2 text-left w-full absolute bottom-0 left-0 right-0 z-10"
|
class="px-2 mb-2 text-left w-full absolute bottom-0 left-0 right-0 z-10"
|
||||||
>
|
>
|
||||||
<div class="flex w-full rounded-xl border border-gray-100 dark:border-gray-850">
|
<div class="flex w-full rounded-xl border border-gray-100 dark:border-gray-850">
|
||||||
|
<div class="flex flex-col w-full rounded-xl bg-white dark:bg-gray-900 dark:text-gray-100">
|
||||||
<div
|
<div
|
||||||
class="max-h-60 flex flex-col w-full rounded-xl bg-white dark:bg-gray-900 dark:text-gray-100"
|
class="m-1 overflow-y-auto p-1 rounded-r-xl space-y-0.5 scrollbar-hidden max-h-60"
|
||||||
|
id="command-options-container"
|
||||||
>
|
>
|
||||||
<div class="m-1 overflow-y-auto p-1 rounded-r-xl space-y-0.5 scrollbar-hidden">
|
|
||||||
{#each filteredItems as item, idx}
|
{#each filteredItems as item, idx}
|
||||||
<button
|
<button
|
||||||
class=" px-3 py-1.5 rounded-xl w-full text-left flex justify-between items-center {idx ===
|
class=" px-3 py-1.5 rounded-xl w-full text-left flex justify-between items-center {idx ===
|
||||||
|
@ -71,10 +71,11 @@
|
|||||||
class="px-2 mb-2 text-left w-full absolute bottom-0 left-0 right-0 z-10"
|
class="px-2 mb-2 text-left w-full absolute bottom-0 left-0 right-0 z-10"
|
||||||
>
|
>
|
||||||
<div class="flex w-full rounded-xl border border-gray-100 dark:border-gray-850">
|
<div class="flex w-full rounded-xl border border-gray-100 dark:border-gray-850">
|
||||||
|
<div class="flex flex-col w-full rounded-xl bg-white dark:bg-gray-900 dark:text-gray-100">
|
||||||
<div
|
<div
|
||||||
class="max-h-60 flex flex-col w-full rounded-xl bg-white dark:bg-gray-900 dark:text-gray-100"
|
class="m-1 overflow-y-auto p-1 rounded-r-lg space-y-0.5 scrollbar-hidden max-h-60"
|
||||||
|
id="command-options-container"
|
||||||
>
|
>
|
||||||
<div class="m-1 overflow-y-auto p-1 rounded-r-lg space-y-0.5 scrollbar-hidden">
|
|
||||||
{#each filteredItems as model, modelIdx}
|
{#each filteredItems as model, modelIdx}
|
||||||
<button
|
<button
|
||||||
class="px-3 py-1.5 rounded-xl w-full text-left {modelIdx === selectedIdx
|
class="px-3 py-1.5 rounded-xl w-full text-left {modelIdx === selectedIdx
|
||||||
|
@ -180,10 +180,11 @@
|
|||||||
class="px-2 mb-2 text-left w-full absolute bottom-0 left-0 right-0 z-10"
|
class="px-2 mb-2 text-left w-full absolute bottom-0 left-0 right-0 z-10"
|
||||||
>
|
>
|
||||||
<div class="flex w-full rounded-xl border border-gray-100 dark:border-gray-850">
|
<div class="flex w-full rounded-xl border border-gray-100 dark:border-gray-850">
|
||||||
|
<div class="flex flex-col w-full rounded-xl bg-white dark:bg-gray-900 dark:text-gray-100">
|
||||||
<div
|
<div
|
||||||
class="max-h-60 flex flex-col w-full rounded-xl bg-white dark:bg-gray-900 dark:text-gray-100"
|
class="m-1 overflow-y-auto p-1 space-y-0.5 scrollbar-hidden max-h-60"
|
||||||
|
id="command-options-container"
|
||||||
>
|
>
|
||||||
<div class="m-1 overflow-y-auto p-1 space-y-0.5 scrollbar-hidden">
|
|
||||||
{#each filteredPrompts as prompt, promptIdx}
|
{#each filteredPrompts as prompt, promptIdx}
|
||||||
<button
|
<button
|
||||||
class=" px-3 py-1.5 rounded-xl w-full text-left {promptIdx === selectedPromptIdx
|
class=" px-3 py-1.5 rounded-xl w-full text-left {promptIdx === selectedPromptIdx
|
||||||
|
Loading…
Reference in New Issue
Block a user