improve ai scrolling

This commit is contained in:
tglide committed 2023-08-28 13:58:35 +01:00
1 parent 77c879df76
commit 4d24095bc4
2 files changed
+8 -16

No files matched your search

+4 -1
View File
@@ -105,7 +105,9 @@
})}
clearOnCallback={false}
on:keydown={(e) => {
e.detail.cancel();
if (e.detail.key !== 'Escape') {
e.detail.cancel();
}
}}
--min-height="40rem"
--max-height="52.5rem">
@@ -117,6 +119,7 @@
<i class="icon-question-mark-circle" />
<span>{option.label}</span>
</div>
<p>cool</p>
{#if $isLoading || answer}
<div class="content">
+4 -15
View File
@@ -1,6 +1,5 @@
<script lang="ts">
import { commandGroupRanks, type CommandGroup, type Command } from '../commands';
import { commandGroupRanks, type Command, type CommandGroup } from '../commands';
// This is the template for all panels used in the command center.
// Use this component when you want to create a new panel.
@@ -82,19 +81,9 @@
tick().then(() => {
if (!cardEl) return;
const resultEls = Array.from(contentEl.querySelectorAll('.result'));
const selectedEl = contentEl.querySelector('[data-selected]');
const selectedIdx = resultEls.indexOf(selectedEl);
if (selectedIdx === 0) {
contentEl.scrollTo({
top: 0
});
} else if (selectedIdx === resultEls.length - 1) {
contentEl.scrollTo({
top: contentEl.scrollHeight
});
} else if (selectedEl) {
if (selectedEl) {
selectedEl.scrollIntoView({
block: 'nearest'
});
@@ -276,6 +265,7 @@
</div>
<div class="content" bind:this={contentEl}>
<slot />
{#if groupsAndOptions}
<ul class="options">
{#each groupsAndOptions as item, i}
@@ -320,8 +310,6 @@
</li>
{/each}
</ul>
{:else}
<slot />
{/if}
</div>
@@ -512,6 +500,7 @@
.result {
position: relative;
scroll-margin-block: 0.5rem;
.bg {
position: absolute;