Skip to content

Conversation

@vdonato
Copy link
Collaborator

@vdonato vdonato commented Jan 21, 2021

It turns out the bug in #2543 appears only when there are enough elements in a Dataframe for a scrollbar to be necessary to display all the data. In the case where we need a vertical scrollbar, the width that we provide to the MultiGrid we're using to render our Dataframe ends up being slightly too small due to the presence of the scrollbar. This causes a horizontal scrollbar to appear. The other case is analogous.

To fix this, we borrowed a helper function from react-bootstrap/dom-helpers for getting the width of scrollbars, then used the helper to fix our rendering dimensions calculations to take scrollbars into account.

Closes #2543

@vdonato vdonato force-pushed the df_scrollbar branch 2 times, most recently from 49778b8 to 1a4025a Compare January 21, 2021 18:48
@vdonato
Copy link
Collaborator Author

vdonato commented Jan 21, 2021

@asaini: My PR comment gives a pretty good description of the changes made, but the TL; DR version of the changes to look for vs the current behavior on the HEAD of develop are the cases where

  • a dataframe has tons of columns but few rows so only a horizontal scrollbar is needed
  • the analogous case with a bunch of rows and few columns

@vdonato vdonato marked this pull request as ready for review January 22, 2021 02:37
@vdonato vdonato requested a review from a team January 22, 2021 02:37
Copy link
Contributor

@akrolsmir akrolsmir left a comment

Choose a reason for hiding this comment

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

Looks great! To get the snapshot tests to pass, you'll want to grab the failing diff.png and run it through the diffmazing cropper, then put the new snapshot in this PR.

Copy link
Collaborator

@kmcgrady kmcgrady left a comment

Choose a reason for hiding this comment

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

The solution is less than ideal, but I think might have to be the path.

In terms of unit testing, here are some ideas that might work:

  • you can use enzyme's mount (or from lib/test_util) and utilize the getDOMNode and verify the offset and clientWidth are the same.
  • If that doesn't work, the e2e test should be able to resolve this as well, both in a snapshot test (the test should not display scrollbars) and doing the same check for offsetWidth and clientWidth

@vdonato vdonato force-pushed the df_scrollbar branch 3 times, most recently from 972729d to f957dfe Compare January 23, 2021 00:10
Copy link
Collaborator Author

@vdonato vdonato left a comment

Choose a reason for hiding this comment

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

Thanks for the reviews @akrolsmir, @kmcgrady! May be worth taking a second glance at things to make sure the tests seem sane.

@kmcgrady
Copy link
Collaborator

Looks reasonable, just got to update the snapshot for the cypress test. Let me know if you need help with that.

And then @asaini should take a look at it for product review.

@vdonato vdonato force-pushed the df_scrollbar branch 4 times, most recently from ed58f39 to ad0d687 Compare January 25, 2021 20:51
At least this is a pretty strong incentive to fix the currently-broken Docker
image for running cypress 😐
@asaini
Copy link

asaini commented Jan 26, 2021

LGTM 👍

@vdonato vdonato merged commit 8bd92f3 into streamlit:develop Jan 26, 2021
@vdonato vdonato deleted the df_scrollbar branch January 26, 2021 20:47
tconkling added a commit to tconkling/streamlit that referenced this pull request Jan 26, 2021
* develop:
  Take scrollbars into account when computing Dataframe dimensions (streamlit#2622)
tconkling added a commit to tconkling/streamlit that referenced this pull request Jan 27, 2021
* develop:
  ReportContext constructs its own widget_ids_this_run (streamlit#2669)
  Add types to report_thread.py (streamlit#2665)
  Take scrollbars into account when computing Dataframe dimensions (streamlit#2622)
  Revert "Revert "Revert "Add anchors to Markdown headers (streamlit#2513)""" (streamlit#2664)
  ♻️ Remove "_proto" from "data_frame_proto.py" (streamlit#2640)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable dataframe horizontal scrollbar

4 participants