Skip to content

Commit

Permalink
add auto update floating position on resize
Browse files Browse the repository at this point in the history
  • Loading branch information
SerhiiTsybulskyi committed Jun 21, 2024
1 parent dd7bd54 commit 8f57ef9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/form/Select/SingleSelect.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const InvalidValues = () => {
export const OptionsArray = () => {
const [value, setValue] = useState<string | null>('github');
return (
<div style={{ width: 300 }}>
<div style={{ width: 300, marginTop: '100px' }}>
<Select value={value} onChange={v => setValue(v)}>
{options.map(o => (
<SelectOption key={o.value} value={o.value}>
Expand Down
6 changes: 4 additions & 2 deletions src/utils/Position/usePosition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
Middleware,
flip,
limitShift,
shift
shift,
autoUpdate
} from '@floating-ui/react';

export type Placement = FloatingUIPlacement;
Expand Down Expand Up @@ -58,7 +59,8 @@ export const usePosition = ({
elements: {
reference: isVirtualElement ? null : (reference as Element),
floating: floating
}
},
whileElementsMounted: autoUpdate
});

useEffect(() => {
Expand Down

0 comments on commit 8f57ef9

Please sign in to comment.