opening Panel hides scrollbar on the main page and shifts content
Environment Information
- Package version(s): (6.199.0)
- Browser and OS versions: (Chrome, Win10)
Actual behavior:
when you open Panel, a css class (seen different ones so it's kind of random, css-0, css-32 for example) is added to the body with following css:
overflow: hidden !important;
if you happen to be on a page that has a scrollbar, it makes the scrollbar go away, widen the page and therefor shift the content sideways as much as the width of the scrollbar. It's annoying to the eyes.
Expected behavior:
this doesn't happen when you open Panels in SPO. I can add some JS code to add some margin-right to the body (as much as the width of the scrollbar) if scrollbar is visible but I think this should be handled by Fabric itself maybe?
Any suggestions? am I doing something wrong here?
cheers, Hamed
Have you tried the isBlocking prop? I did a quick CodePen to demo the difference. If isBlocking is false, Panel shouldn't prevent scrolling.
I have the same need. isBlocking prop unable to meet demand If isBlocking = true, Panel cannot be closed on outer click.
hides scrollbar at OverlayBase.tsx
export class OverlayBase extends BaseComponent<IOverlayProps, {}> {
public componentDidMount(): void {
disableBodyScroll();
}
...
}
So parent component settings should be allowed to overlay props My suggestion a month ago.
-
Panel Modal component add overlayProps. #9668 #9696
-
Overlay component add onOverlayDidMount and onOverlayWillUnmount #9670 //state: Closed
-
Overlay component add bodyScroll props #9784 But it doesn't seem to have been accepted.
public componentDidMount(): void {
if(this.props.bodyScroll){
disableBodyScroll();
}
}
@x73x63 If I read your post correctly #9784 is the only outstanding issue. It is still open and you can add comments there. I can also follow up. I would like to leave the scope of this issue as originally reported for clarity and resolution.
Have you tried the
isBlockingprop? I did a quick CodePen to demo the difference. IfisBlockingis false, Panel shouldn't prevent scrolling.
well that's not ideal, I'd rather use isBlocking to manage blocking. Also, having two scrollbars right next to each other is bad practice. I think hiding the scrollbar is fine, we just need some extra css and js to avoid shifting of content.
If this example is showing two scrollbars, it's because the CodePen view window was very short. View port height would be a consideration in all Panel non-blocking cases.
This isn't just a matter of hiding or showing the scrollbar. The blocking cases also prevents users from scrolling the page, which is why the scrollbar disappears. Do you want users to be able to scroll the page in your use case?
If this example is showing two scrollbars, it's because the CodePen view window was very short. View port height would be a consideration in all
Panelnon-blocking cases.This isn't just a matter of hiding or showing the scrollbar. The blocking cases also prevents users from scrolling the page, which is why the scrollbar disappears. Do you want users to be able to scroll the page in your use case?
No actually I want the scrollbar to disappear and bring the focus to the Panel content. Imagine a page full of responsive components, News web part with pictures and lots of other things. Almost every component's width is in percentage relative to the width of the browser view.
Now you want to read one of the news items, it opens in a Panel. which covers lets say half of your display, you still see everything else on the other half of the display getting stretched because the scrollbar disappeared and the whole view is wider and 33% of it for a news article thumbnail is more pixels. And then they shrink again when you close the Panel and the scrollbar appears.
We've based lots of our components in our web app solution based on boxes of abstract data and controls to open Panels to see more. And these are single page apps. so users spend a lot of time on these pages and this is not nice to the eye. Compare that to having everything on the main page dead still when you open and close the Panel (but still hide the scrollbar on main page and focus on the Panel content). That stretching effect takes away from the focus on Panel's content.
If I want to fix this myself I have to add code to every React component we've developed using Panel to trigger a function that calculates the width of scrollbar and adds a margin of same size to the right side of body element and undo it when Panel is closed. I can do that but if this can be an issue for others which I think it can, best if it's handled in Fabric.
Do you have a fix for Panel in mind? Rather than change your source, you could make a PR to add optional styling to Panel to account for the space taken by scroll bar. The primary issue I see is knowing when the scrollbar is present and how much space it takes up.
Do you have a fix for
Panelin mind? Rather than change your source, you could make a PR to add optional styling toPanelto account for the space taken by scroll bar. The primary issue I see is knowing when the scrollbar is present and how much space it takes up.
I don't think pure css would be enough. As you said we need to find out if we have a scrollbar or not and how wide it is so we need some JavaScript code.
I didn't say css, when we use the word 'styling' it's typically referring to JS styling along with the JavaScript required to support it. Is this a PR you'd like to take a stab at?
yeah I'm absolutely in for writing the code, I just have no idea about the process.
We have a document regarding contributing. If you have more specific questions not addressed here feel free to contact me outside of GitHub. If you are an MS employee, please consider associating your GitHub account with the MS org so others can see your alias.
Ok great, I'll read the documentation and bother you if still was unsure of something. I work for a private firm that is a MS Gold partner but other than that not associated with MS.
This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fabric React!