Skip to content

Commit

Permalink
Merge pull request open-webui#5961 from open-webui/dev
Browse files Browse the repository at this point in the history
refac: floating buttons
  • Loading branch information
tjbck authored Oct 7, 2024
2 parents 7cebcf0 + 6e8e045 commit ad7bc62
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/lib/components/chat/Messages/ContentRenderer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@
let floatingInputValue = '';
const updateButtonPosition = (event) => {
if (
!contentContainerElement?.contains(event.target) &&
!buttonsContainerElement?.contains(event.target)
) {
closeFloatingButtons();
return;
}
setTimeout(async () => {
await tick();
// Check if the event target is within the content container
if (!contentContainerElement?.contains(event.target)) {
closeFloatingButtons();
return;
}
if (!contentContainerElement?.contains(event.target)) return;
let selection = window.getSelection();
Expand All @@ -51,8 +55,9 @@
// Calculate space available on the right
const spaceOnRight = parentRect.width - (left + buttonsContainerElement.offsetWidth);
if (spaceOnRight < 0) {
// Not enough space on the right, position using 'right'
let thirdScreenWidth = window.innerWidth / 3;
if (spaceOnRight < thirdScreenWidth) {
const right = parentRect.right - rect.right;
buttonsContainerElement.style.right = `${right}px`;
buttonsContainerElement.style.left = 'auto'; // Reset left
Expand Down

0 comments on commit ad7bc62

Please sign in to comment.