New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panel, Modal, Overlay: Optional prop that disables bodyscroll block on touch devices #11339
Changes from 4 commits
00c16da
0b8a5f3
a4e0df6
8bdd921
329e9cb
23e5068
4fb954d
2f93c87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "scroll.ts: extended event handler provided by _makeElementScrollAllower with allowIosOverscroll argument to make blocking of body scroll on touch devices optional", | ||
"packageName": "@uifabric/utilities", | ||
"email": "dmitriy.ravdin@siemens.com", | ||
"commit": "00c16da9f0d9ee3de29c6de6a0aa32d50397cdcc", | ||
"date": "2019-11-28T21:34:32.268Z" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "modal, panel, overlay components: added optional prop allowIosBodyScroll to allow body scroll on touch devices", | ||
"packageName": "office-ui-fabric-react", | ||
"email": "dmitriy.ravdin@siemens.com", | ||
"commit": "00c16da9f0d9ee3de29c6de6a0aa32d50397cdcc", | ||
"date": "2019-11-28T21:34:30.900Z" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ export class ModalBase extends BaseComponent<IModalProps, IDialogState> implemen | |
private _scrollableContent: HTMLDivElement | null; | ||
private _lastSetX: number; | ||
private _lastSetY: number; | ||
private _allowIosBodyScroll: boolean; | ||
private _hasRegisteredKeyUp: boolean; | ||
|
||
constructor(props: IModalProps) { | ||
|
@@ -66,6 +67,9 @@ export class ModalBase extends BaseComponent<IModalProps, IDialogState> implemen | |
this._warnDeprecations({ | ||
onLayerDidMount: 'layerProps.onLayerDidMount' | ||
}); | ||
|
||
const { allowIosBodyScroll = false } = this.props; | ||
this._allowIosBodyScroll = allowIosBodyScroll; | ||
} | ||
|
||
// tslint:disable-next-line function-name | ||
|
@@ -238,7 +242,14 @@ export class ModalBase extends BaseComponent<IModalProps, IDialogState> implemen | |
onDismiss={onDismiss} | ||
> | ||
<div className={classNames.root}> | ||
{!isModeless && <Overlay isDarkThemed={isDarkOverlay} onClick={isBlocking ? undefined : (onDismiss as any)} {...overlay} />} | ||
{!isModeless && ( | ||
<Overlay | ||
isDarkThemed={isDarkOverlay} | ||
onClick={isBlocking ? undefined : (onDismiss as any)} | ||
allowIosBodyScroll={this._allowIosBodyScroll} | ||
{...overlay} | ||
/> | ||
)} | ||
{dragOptions ? ( | ||
<DraggableZone | ||
handleSelector={dragOptions.dragHandleSelector || `.${classNames.main.split(' ')[0]}`} | ||
|
@@ -270,7 +281,7 @@ export class ModalBase extends BaseComponent<IModalProps, IDialogState> implemen | |
// Allow the user to scroll within the modal but not on the body | ||
private _allowScrollOnModal = (elt: HTMLDivElement | null): void => { | ||
if (elt) { | ||
allowScrollOnElement(elt, this._events); | ||
allowScrollOnElement(elt, this._events, this._allowIosBodyScroll); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's missing from the current allowScrollOnElement that misses the touch capability? Instead of making a separate, new method to handle touch, can we fill in the missing gaps to handle touch in allowScrollOnElement? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allowScrollOnElement allows scrolling of content within the element and when top or botton of content is reached, events are blocked, this way it prevents overscrolling _preventOverscrolling where body would be scrolled. But this creates an issue, because _preventOverscrolling blocks all touch events. Example is my original issue #10982 where if you are zoomed in on mobile device and open panel, you can not pan around using content of panel because of _preventOverscrolling event handler, this way user is stuck (he cant reach close button for example) and all he can do is scroll panel content. We need to somehow allow the user to scroll the content, but also be able to pan around while zoomed in. I am not even sure it is possible to differentiate touch events that will scroll the body and from ones that will pan your zoomed in view. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this PR, i could create Panel and Modal components that dont block touch events. This is not perfect solution, as it allows body scrolling behind the overlay, which is a bit irritating, but UI is still intuitively usable. Where in current state, user is stuck in not usable UI. |
||
} else { | ||
this._events.off(this._scrollableContent); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ export function addDirectionalKeyCode(which: number): void; | |
export function addElementAtIndex<T>(array: T[], index: number, itemToAdd: T): T[]; | ||
|
||
// @public | ||
export const allowScrollOnElement: (element: HTMLElement | null, events: EventGroup) => void; | ||
export const allowScrollOnElement: (element: HTMLElement | null, events: EventGroup, allowIosOverscroll?: boolean) => void; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a boolean arg is usually not recommended - can we circumvent this without a boolean arg? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See: https://github.com/OfficeDev/office-ui-fabric-react/wiki/Pull-request-reviewing-guidance
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originaly i tought of this, but this would create duplicate code. It would be just 2 slighty different versions of _makeElementScrollAllower. But now i see if you remove the code that is needed for _preventOverscrolling handler, not much is left and duplicate code will be minimal. |
||
|
||
// @public | ||
export const anchorProperties: string[]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to
allowTouchBodyScroll
or something non-platform specific.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is good point, i will change it to allowTouchBodyScroll, i think i took the name from _disableIosBodyScroll