Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ 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;
const rootHeight = this._root.value.getBoundingClientRect().height;
needsVerticalScrollBar = rootHeight > 0
&& this._root.value.firstElementChild.getBoundingClientRect().height > rootHeight;

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.

Yeah, I'm concerned that this is overkill and this might result in too much of a perf hit if it's run too much... but if it doesn't get run too often it should be much of an issue. Do you try with a buffer and was it reliable for making sure the scrollbar did not appear (vs calling getBoundingClientRect)? I created a test on jsperf to compare clientHight vs getBoundClientRect.height https://jsperf.com/clienthightvsgetboundingclientrect so we can get an idea for what the perf implications are. I'd like to get @dzearing 's thoughts on this

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.

Thank you for the link, that is really neat. I looked more into this and scrollbar recalculation can happen quite often in the case of comboboxes when we are hovering over items and updating selection. From jsperf it does look like BoundingClientRect is 90% slower than ClientHeight. Updating the code to not use that and instead allow for a 1px diff between the comparison seems to do the trick and I dont think it could cause other problems. It does feel a bit too hacky to me, but I guess better than the perf hit. I will update the code in the next iteration.

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