Skip to content

Commit d912d6a

Browse files
author
Dominik Dosoudil
committed
fix(portal): Replace AbortController with removeEventListener to support older browsers
1 parent d13670b commit d912d6a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/addons/Portal/Portal.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,23 @@ function Portal(props) {
152152
if (!hideOnScroll) {
153153
return
154154
}
155-
const abortController = new AbortController()
156155

157-
window.addEventListener(
158-
'scroll',
159-
(e) => {
160-
debug('handleHideOnScroll()')
156+
const handleScroll = (e) => {
157+
debug('handleHideOnScroll()')
161158

162-
// Do not hide the popup when scroll comes from inside the popup
163-
// https://github.com/Semantic-Org/Semantic-UI-React/issues/4305
164-
if (_.isElement(e.target) && contentRef.current.contains(e.target)) {
165-
return
166-
}
159+
// Do not hide the popup when scroll comes from inside the popup
160+
// https://github.com/Semantic-Org/Semantic-UI-React/issues/4305
161+
if (_.isElement(e.target) && contentRef.current.contains(e.target)) {
162+
return
163+
}
167164

168-
closePortal(e)
169-
},
170-
{ signal: abortController.signal, passive: true },
171-
)
165+
closePortal(e)
166+
}
167+
168+
window.addEventListener('scroll', handleScroll, { passive: true })
172169

173170
return () => {
174-
abortController.abort()
171+
window.removeEventListener('scroll', handleScroll)
175172
}
176173
}, [closePortal, hideOnScroll])
177174

0 commit comments

Comments
 (0)