Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Fix scroll bar shows when it should not.",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "ddlbrena@microsoft.com"
}
16 changes: 14 additions & 2 deletions packages/office-ui-fabric-react/src/components/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,20 @@ export class Popup extends BaseComponent<IPopupProps, IPopupState> {
private _getScrollBar() {
let needsVerticalScrollBar = false;
if (this._root && this._root.value && this._root.value.firstElementChild) {
needsVerticalScrollBar = this._root.value.clientHeight > 0
&& this._root.value.firstElementChild.clientHeight > this._root.value.clientHeight;
// ClientHeight returns the client height of an element rounded to an
// integer. On some browsers at different zoom levels this rounding
// can generate different results for the root container and child even
// though they are the same height. This causes us to show a scroll bar
// when not needed. Ideally we would use BoundingClientRect().height
// instead however seems that the API is 90% slower than using ClientHeight.
// Therefore instead we will calculate the difference between heights and
// allow for a 1px difference to still be considered ok and not show the
// scroll bar.
const rootHeight = this._root.value.clientHeight;
const firstChildHeight = this._root.value.firstElementChild.clientHeight;
if (rootHeight > 0 && firstChildHeight > rootHeight) {
needsVerticalScrollBar = (firstChildHeight - rootHeight) > 1;

@jspurlin jspurlin Apr 13, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if rootHeight is <= 0?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you could get into a situation where the logic is different now than it used to be

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I am leaving that as it was, which it just does not show the scrollbar, not sure when that happens


In reply to: 181263841 [](ancestors = 181263841)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... I missed the if statement on line 129 when I made that comment...

}
}
if (this.state.needsVerticalScrollBar !== needsVerticalScrollBar) {
this.setState({
Expand Down