Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 4ddde9d

Browse files
authored
fix: change initial position style based on positionFixed prop (#336)
1 parent f0b9040 commit 4ddde9d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Popper.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type PopperState = {
4747
};
4848

4949
const initialStyle = {
50-
position: 'absolute',
5150
top: 0,
5251
left: 0,
5352
opacity: 0,
@@ -113,14 +112,18 @@ export class InnerPopper extends React.Component<PopperProps, PopperState> {
113112
},
114113
});
115114

116-
getPopperStyle = () =>
117-
!this.popperNode || !this.state.data
118-
? initialStyle
115+
getPopperStyle = () => {
116+
const computedInitialStyle = {
117+
...initialStyle,
118+
position: this.props.positionFixed ? 'fixed' : 'absolute',
119+
}
120+
return !this.popperNode || !this.state.data
121+
? computedInitialStyle
119122
: {
120123
position: this.state.data.offsets.popper.position,
121124
...this.state.data.styles,
122125
};
123-
126+
}
124127
getPopperPlacement = () =>
125128
!this.state.data ? undefined : this.state.placement;
126129

0 commit comments

Comments
 (0)