1- import EventStack from '@semantic-ui-react/event-stack'
21import cx from 'clsx'
32import _ from 'lodash'
43import PropTypes from 'prop-types'
@@ -14,9 +13,9 @@ import {
1413 getUnhandledProps ,
1514 makeDebugger ,
1615 SUI ,
16+ useIsomorphicLayoutEffect ,
1717 useKeyOnly ,
1818 useKeyOrValueAndKey ,
19- useIsomorphicLayoutEffect ,
2019 useMergedRefs ,
2120 usePrevious ,
2221} from '../../lib'
@@ -72,11 +71,10 @@ function getPortalProps(props) {
7271 * Splits props for Portal & Popup.
7372 *
7473 * @param {Object } unhandledProps
75- * @param {Boolean } closed
7674 * @param {Boolean } disabled
7775 */
78- function partitionPortalProps ( unhandledProps , closed , disabled ) {
79- if ( closed || disabled ) {
76+ function partitionPortalProps ( unhandledProps , disabled ) {
77+ if ( disabled ) {
8078 return { }
8179 }
8280
@@ -124,7 +122,7 @@ const Popup = React.forwardRef(function (props, ref) {
124122 eventsEnabled = true ,
125123 flowing,
126124 header,
127- hideOnScroll,
125+ hideOnScroll = false ,
128126 inverted,
129127 offset,
130128 pinned = false ,
@@ -139,18 +137,11 @@ const Popup = React.forwardRef(function (props, ref) {
139137 wide,
140138 } = props
141139
142- const [ closed , setClosed ] = React . useState ( false )
143-
144140 const unhandledProps = getUnhandledProps ( Popup , props )
145- const { contentRestProps, portalRestProps } = partitionPortalProps (
146- unhandledProps ,
147- closed ,
148- disabled ,
149- )
141+ const { contentRestProps, portalRestProps } = partitionPortalProps ( unhandledProps , disabled )
150142
151143 const elementRef = useMergedRefs ( ref )
152144 const positionUpdate = React . useRef ( )
153- const timeoutId = React . useRef ( )
154145 const triggerRef = React . useRef ( )
155146 const zIndexWasSynced = React . useRef ( false )
156147
@@ -160,12 +151,6 @@ const Popup = React.forwardRef(function (props, ref) {
160151
161152 usePositioningEffect ( popperDependencies , positionUpdate )
162153
163- React . useEffect ( ( ) => {
164- return ( ) => {
165- clearTimeout ( timeoutId . current )
166- }
167- } , [ ] )
168-
169154 // ----------------------------------------
170155 // Handlers
171156 // ----------------------------------------
@@ -180,24 +165,6 @@ const Popup = React.forwardRef(function (props, ref) {
180165 _ . invoke ( props , 'onOpen' , e , { ...props , open : true } )
181166 }
182167
183- const handleHideOnScroll = ( e ) => {
184- debug ( 'handleHideOnScroll()' )
185-
186- // Do not hide the popup when scroll comes from inside the popup
187- // https://github.com/Semantic-Org/Semantic-UI-React/issues/4305
188- if ( _ . isElement ( e . target ) && elementRef . current . contains ( e . target ) ) {
189- return
190- }
191-
192- setClosed ( true )
193-
194- timeoutId . current = setTimeout ( ( ) => {
195- setClosed ( false )
196- } , 50 )
197-
198- handleClose ( e )
199- }
200-
201168 const handlePortalMount = ( e ) => {
202169 debug ( 'handlePortalMount()' )
203170 _ . invoke ( props , 'onMount' , e , props )
@@ -254,7 +221,6 @@ const Popup = React.forwardRef(function (props, ref) {
254221 ) : (
255222 children
256223 ) }
257- { hideOnScroll && < EventStack on = { handleHideOnScroll } name = 'scroll' target = 'window' /> }
258224 </ ElementType >
259225 )
260226
@@ -276,7 +242,7 @@ const Popup = React.forwardRef(function (props, ref) {
276242 } )
277243 }
278244
279- if ( closed || disabled ) {
245+ if ( disabled ) {
280246 return trigger
281247 }
282248
@@ -335,6 +301,7 @@ const Popup = React.forwardRef(function (props, ref) {
335301 onUnmount = { handlePortalUnmount }
336302 trigger = { trigger }
337303 triggerRef = { triggerRef }
304+ hideOnScroll = { hideOnScroll }
338305 >
339306 < Popper
340307 modifiers = { modifiers }
0 commit comments