Skip to content

Commit 5c9db40

Browse files
authored
Revert "Prevent scrolling while popovers are open (#3475)" (#3583)
This reverts commit b10ddaa.
1 parent 6dd6bd8 commit 5c9db40

File tree

8 files changed

+17
-36
lines changed

8 files changed

+17
-36
lines changed

packages/@adobe/spectrum-css-temp/components/underlay/index.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ governing permissions and limitations under the License.
3737
/* Exit animations */
3838
transition: opacity var(--spectrum-dialog-background-exit-animation-duration) var(--spectrum-dialog-background-exit-animation-ease) var(--spectrum-dialog-background-exit-animation-delay),
3939
visibility 0ms linear calc(var(--spectrum-dialog-background-exit-animation-delay) + var(--spectrum-dialog-background-exit-animation-duration));
40-
41-
&.spectrum-Underlay--isTransparent {
42-
transition: none;
43-
background: none;
44-
}
4540
}
4641

4742
.spectrum-Underlay.is-open {

packages/@react-spectrum/dialog/src/DialogTrigger.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ function PopoverTrigger({state, targetRef, trigger, content, hideArrow, isKeyboa
173173
placement={placement}
174174
arrowProps={arrowProps}
175175
isKeyboardDismissDisabled={isKeyboardDismissDisabled}
176-
hideArrow={hideArrow}
177-
preventScroll>
176+
hideArrow={hideArrow}>
178177
{typeof content === 'function' ? content(state.close) : content}
179178
</Popover>
180179
);

packages/@react-spectrum/menu/src/MenuTrigger.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ function MenuTrigger(props: SpectrumMenuTriggerProps, ref: DOMRef<HTMLElement>)
109109
placement={placement}
110110
hideArrow
111111
onClose={state.close}
112-
shouldCloseOnBlur
113-
preventScroll>
112+
shouldCloseOnBlur>
114113
{contents}
115114
</Popover>
116115
);

packages/@react-spectrum/menu/stories/MenuTrigger.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ storiesOf('MenuTrigger', module)
489489
)
490490
)
491491
.add(
492-
'menu should prevent scrolling',
492+
'menu closes on scroll',
493493
() => (
494494
<div style={{height: 100, display: 'flex'}}>
495495
<div style={{paddingTop: 100, height: 100, overflow: 'auto', background: 'antiquewhite'}}>
496496
<div style={{height: 200}}>
497-
<div>Shouldn't be able to scroll here while Menu is open.</div>
497+
<div>Scrolling here will close the Menu</div>
498498
<MenuTrigger onOpenChange={action('onOpenChange')} defaultOpen>
499499
<ActionButton
500500
onPress={action('press')}
@@ -514,7 +514,7 @@ storiesOf('MenuTrigger', module)
514514
</div>
515515
<div style={{paddingTop: 100, height: 100, overflow: 'auto', flex: 1, background: 'grey'}}>
516516
<div style={{height: 200}}>
517-
Also shouldn't be able to scroll here while Menu is open.
517+
Scrolling here won't close the Menu
518518
</div>
519519
</div>
520520
</div>

packages/@react-spectrum/overlays/src/Popover.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
*/
1212

1313
import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
14-
import {DOMRef, FocusableElement} from '@react-types/shared';
14+
import {DOMRef} from '@react-types/shared';
1515
import {mergeProps, useLayoutEffect} from '@react-aria/utils';
1616
import {Overlay} from './Overlay';
1717
import overrideStyles from './overlays.css';
1818
import {PlacementAxis, PopoverProps} from '@react-types/overlays';
19-
import React, {DOMAttributes, forwardRef, HTMLAttributes, ReactNode, RefObject, useRef, useState} from 'react';
19+
import React, {forwardRef, HTMLAttributes, ReactNode, RefObject, useRef, useState} from 'react';
2020
import styles from '@adobe/spectrum-css-temp/components/popover/vars.css';
21-
import {Underlay} from './Underlay';
22-
import {useModal, useOverlay, usePreventScroll} from '@react-aria/overlays';
21+
import {useModal, useOverlay} from '@react-aria/overlays';
2322

2423
interface PopoverWrapperProps extends HTMLAttributes<HTMLElement> {
2524
children: ReactNode,
@@ -31,9 +30,7 @@ interface PopoverWrapperProps extends HTMLAttributes<HTMLElement> {
3130
shouldCloseOnBlur?: boolean,
3231
isKeyboardDismissDisabled?: boolean,
3332
isNonModal?: boolean,
34-
isDismissable?: boolean,
35-
overlayProps: DOMAttributes<FocusableElement>,
36-
preventScroll?: boolean
33+
isDismissable?: boolean
3734
}
3835

3936
/**
@@ -61,15 +58,13 @@ function Popover(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {
6158
isKeyboardDismissDisabled,
6259
isNonModal,
6360
isDismissable = true,
64-
preventScroll,
6561
...otherProps
6662
} = props;
6763
let domRef = useDOMRef(ref);
6864
let {styleProps} = useStyleProps(props);
69-
let {overlayProps, underlayProps} = useOverlay({...props, isDismissable: isDismissable && props.isOpen}, domRef);
65+
7066
return (
7167
<Overlay {...otherProps}>
72-
{preventScroll && <Underlay isTransparent {...underlayProps} /> }
7368
<PopoverWrapper
7469
{...styleProps}
7570
ref={domRef}
@@ -80,9 +75,7 @@ function Popover(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {
8075
isKeyboardDismissDisabled={isKeyboardDismissDisabled}
8176
hideArrow={hideArrow}
8277
isNonModal={isNonModal}
83-
isDismissable={isDismissable}
84-
overlayProps={overlayProps}
85-
preventScroll={preventScroll}>
78+
isDismissable={isDismissable}>
8679
{children}
8780
</PopoverWrapper>
8881
</Overlay>
@@ -103,14 +96,12 @@ const PopoverWrapper = forwardRef((props: PopoverWrapperProps, ref: RefObject<HT
10396
isNonModal,
10497
// eslint-disable-next-line @typescript-eslint/no-unused-vars
10598
isDismissable,
106-
overlayProps,
107-
preventScroll,
10899
...otherProps
109100
} = props;
101+
let {overlayProps} = useOverlay({...props, isDismissable: isDismissable && isOpen}, ref);
110102
let {modalProps} = useModal({
111103
isDisabled: isNonModal
112104
});
113-
usePreventScroll({isDisabled: !preventScroll});
114105

115106
return (
116107
<div

packages/@react-spectrum/overlays/src/Underlay.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ import React from 'react';
1515
import underlayStyles from '@adobe/spectrum-css-temp/components/underlay/vars.css';
1616

1717
interface UnderlayProps {
18-
isOpen?: boolean,
19-
isTransparent?: boolean
18+
isOpen?: boolean
2019
}
2120

22-
export function Underlay({isOpen, isTransparent}: UnderlayProps) {
21+
export function Underlay({isOpen}: UnderlayProps) {
2322
return (
24-
<div className={classNames(underlayStyles, 'spectrum-Underlay', {'spectrum-Underlay--isTransparent': isTransparent}, {'is-open': isOpen})} />
23+
<div className={classNames(underlayStyles, 'spectrum-Underlay', {'is-open': isOpen})} />
2524
);
2625
}

packages/@react-spectrum/picker/src/Picker.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ function Picker<T extends object>(props: SpectrumPickerProps<T>, ref: DOMRef<HTM
175175
placement={placement}
176176
hideArrow
177177
shouldCloseOnBlur
178-
onClose={state.close}
179-
preventScroll>
178+
onClose={state.close}>
180179
{listbox}
181180
</Popover>
182181
);

packages/@react-types/overlays/src/index.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ export interface PopoverProps extends StyleProps, OverlayProps {
9191
onClose?: () => void,
9292
shouldCloseOnBlur?: boolean,
9393
isNonModal?: boolean,
94-
isDismissable?: boolean,
95-
preventScroll?: boolean
94+
isDismissable?: boolean
9695
}
9796

9897
export interface TrayProps extends StyleProps, OverlayProps {

0 commit comments

Comments
 (0)