Skip to content

Commit

Permalink
fix: Dynamically reposition widget popovers when content changes size
Browse files Browse the repository at this point in the history
Closes #617
  • Loading branch information
alexanderson1993 committed Jul 11, 2024
1 parent 9c82aeb commit 9e68ba9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/app/routes/flight.station/widgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Cards from "@client/cards";
import { q } from "@client/context/AppContext";
import { SVGImageLoader } from "@thorium/ui/SVGImageLoader";
import {
ComponentPropsWithoutRef,
type ComponentType,
type FC,
type ReactElement,
Expand All @@ -12,6 +11,7 @@ import {
import { GamepadConfig, useGamepadStore } from "@client/hooks/useGamepadStore";
import { Popover, Transition } from "@headlessui/react";
import {
autoUpdate,
useClick,
useDismiss,
useFloating,
Expand Down Expand Up @@ -80,10 +80,11 @@ export const Widget: FC<{
}> = ({ name, icon, component: Component, size = "sm" }) => {
const [isOpen, setIsOpen] = useState(false);

const { x, y, strategy, refs, context } = useFloating({
const { x, y, strategy, refs, context, update } = useFloating({
open: isOpen,
onOpenChange: setIsOpen,
placement: "top-end",
whileElementsMounted: autoUpdate,
});

const dismiss = useDismiss(context);
Expand Down

0 comments on commit 9e68ba9

Please sign in to comment.