Skip to content

Commit

Permalink
fix(weg): display preview position were at wrong position
Browse files Browse the repository at this point in the history
  • Loading branch information
luriusTM committed Oct 22, 2024
1 parent 9ac0b60 commit 5fd4804
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/apps/seelenweg/modules/item/infra/UserApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { Popover } from 'antd';
import { memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { SeelenCommand, useWindowFocusChange } from 'seelen-core';
import { SeelenCommand, SeelenWegSide, useWindowFocusChange } from 'seelen-core';

import { BackgroundByLayersV2 } from '../../../components/BackgroundByLayers/infra';
import { updatePreviews } from '../../shared/utils/infra';

import { Selectors } from '../../shared/store/app';

import {
ExtendedPinnedWegItem,
ExtendedTemporalWegItem,
Expand All @@ -30,8 +32,28 @@ export const UserApplication = memo(({ item }: Props) => {
);

const [openPreview, setOpenPreview] = useState(false);
const settings = useSelector(Selectors.settings);

const { t } = useTranslation();
const calculatePlacement = (position: any) => {
switch (position) {
case SeelenWegSide.Bottom: {
return 'top';
}
case SeelenWegSide.Top: {
return 'bottom';
}
case SeelenWegSide.Left: {
return 'right';
}
case SeelenWegSide.Right: {
return 'left';
}
default: {
return 'bottom';
}
}
};

useWindowFocusChange((focused) => {
if (!focused) {
Expand All @@ -57,7 +79,7 @@ export const UserApplication = memo(({ item }: Props) => {
<Popover
open={openPreview}
mouseEnterDelay={0.4}
placement="top"
placement={calculatePlacement(settings.position)}
onOpenChange={(open) => setOpenPreview(open && !!item.opens.length)}
trigger="hover"
arrow={false}
Expand Down

0 comments on commit 5fd4804

Please sign in to comment.