Quellcode durchsuchen

Add 'resize' event listener to list position

Instead of updating the list position only on 'scroll' event, it is now
updated on 'resize' event also.
Sergiu Miclea vor 8 Jahren
Ursprung
Commit
8aa46a0d7e
1 geänderte Dateien mit 2 neuen und 0 gelöschten Zeilen
  1. 2 0
      src/components/molecules/Dropdown/index.jsx

+ 2 - 0
src/components/molecules/Dropdown/index.jsx

@@ -148,6 +148,7 @@ class Dropdown extends React.Component<Props, State> {
     if (this.buttonRef) {
     if (this.buttonRef) {
       this.scrollableParent = DomUtils.getScrollableParent(this.buttonRef)
       this.scrollableParent = DomUtils.getScrollableParent(this.buttonRef)
       this.scrollableParent.addEventListener('scroll', this.handleScroll)
       this.scrollableParent.addEventListener('scroll', this.handleScroll)
+      window.addEventListener('resize', this.handleScroll)
       this.buttonRect = this.buttonRef.getBoundingClientRect()
       this.buttonRect = this.buttonRef.getBoundingClientRect()
     }
     }
   }
   }
@@ -162,6 +163,7 @@ class Dropdown extends React.Component<Props, State> {
 
 
   componentWillUnmount() {
   componentWillUnmount() {
     window.removeEventListener('mousedown', this.handlePageClick, false)
     window.removeEventListener('mousedown', this.handlePageClick, false)
+    window.removeEventListener('resize', this.handleScroll, false)
     this.scrollableParent.removeEventListener('scroll', this.handleScroll, false)
     this.scrollableParent.removeEventListener('scroll', this.handleScroll, false)
   }
   }