Skip to content

Commit 7ab9368

Browse files
author
Vladimir Komolov
committed
Fix OuiPopover does not change position on the scroll (#1184)
Signed-off-by: Vladimir Komolov <[email protected]>
1 parent a17c839 commit 7ab9368

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- Extract build archive into a folder for OSD integration test CI ([#1075](https://github.com/opensearch-project/oui/pull/1075))
2929
- Correct file path for import of Query component ([#1069](https://github.com/opensearch-project/oui/pull/1069))
3030
- Fix "Guidelines" documentation links rendering blank pages ([#1111](https://github.com/opensearch-project/oui/pull/1111))
31+
- Fix OuiPopover does not change position on the scroll ([#1184](https://github.com/opensearch-project/oui/pull/1184))
3132

3233
### 🚞 Infrastructure
3334

src/components/popover/popover.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ export class OuiPopover extends Component<Props, State> {
532532
}
533533

534534
if (this.props.repositionOnScroll) {
535-
window.addEventListener('scroll', this.positionPopoverFixed);
535+
window.addEventListener('scroll', this.positionPopoverFixed, true);
536536
}
537537
}
538538

@@ -545,9 +545,9 @@ export class OuiPopover extends Component<Props, State> {
545545
// update scroll listener
546546
if (prevProps.repositionOnScroll !== this.props.repositionOnScroll) {
547547
if (this.props.repositionOnScroll) {
548-
window.addEventListener('scroll', this.positionPopoverFixed);
548+
window.addEventListener('scroll', this.positionPopoverFixed, true);
549549
} else {
550-
window.removeEventListener('scroll', this.positionPopoverFixed);
550+
window.removeEventListener('scroll', this.positionPopoverFixed, true);
551551
}
552552
}
553553

@@ -565,7 +565,7 @@ export class OuiPopover extends Component<Props, State> {
565565
}
566566

567567
componentWillUnmount() {
568-
window.removeEventListener('scroll', this.positionPopoverFixed);
568+
window.removeEventListener('scroll', this.positionPopoverFixed, true);
569569
clearTimeout(this.respositionTimeout);
570570
clearTimeout(this.closingTransitionTimeout);
571571
cancelAnimationFrame(this.closingTransitionAnimationFrame!);

0 commit comments

Comments
 (0)