From 066947224a28ff5704b45f8b1e1242473b95ad27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Tue, 10 Dec 2024 14:55:20 +0100 Subject: [PATCH 01/18] Try to fix floating --- src/components/List/List.tsx | 2 +- src/components/Select/Select.tsx | 14 +-- src/components/Select/SelectWrapper.tsx | 109 +++++++++++------------- src/hooks/useFloating.ts | 7 +- 4 files changed, 63 insertions(+), 69 deletions(-) diff --git a/src/components/List/List.tsx b/src/components/List/List.tsx index 18b5980f..d44cb879 100644 --- a/src/components/List/List.tsx +++ b/src/components/List/List.tsx @@ -8,7 +8,7 @@ export type ListProps = PropsWithBox<{ className?: string; }>; -export const List = forwardRef( +export const List = forwardRef( ({ children, as = "ul", className, ...rest }, ref) => { return ( = PropsWithBox< @@ -114,7 +114,7 @@ const SelectInner = ( onBlur, }); - const { refs, floatingStyles } = useFloating(); + const { refs, floatingStyles } = useFloating(); const labelColor = useMemo((): TextProps["color"] => { if (error) { @@ -131,7 +131,6 @@ const SelectInner = ( return ( ( error={error} className={className} getLabelProps={getLabelProps} - getToggleButtonProps={getToggleButtonProps} + getToggleButtonProps={() => + getToggleButtonProps({ ref: refs.reference }) + } > {startAdornment && typed && startAdornment(value)} @@ -159,7 +160,7 @@ const SelectInner = ( {endAdornment && typed && endAdornment(value)} - + ( {isOpen && options?.map((item, index) => ( diff --git a/src/components/Select/SelectWrapper.tsx b/src/components/Select/SelectWrapper.tsx index 07ce18f7..6630815e 100644 --- a/src/components/Select/SelectWrapper.tsx +++ b/src/components/Select/SelectWrapper.tsx @@ -2,7 +2,7 @@ Do not expose this file, it's for internal purposes only. */ import { UseSelectPropGetters } from "downshift"; -import { ReactNode, forwardRef } from "react"; +import { ReactNode } from "react"; import { classNames } from "~/utils"; @@ -23,69 +23,62 @@ type SelectWrapperProps = LabelVariants & { getLabelProps: UseSelectPropGetters