Skip to content
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

Add CSS to allow scrolling of ipywidget #1760

Merged
merged 1 commit into from
May 23, 2024

Conversation

gabalafou
Copy link
Collaborator

@gabalafou gabalafou commented Apr 8, 2024

This PR addresses one of the issues in #1740: missing horizontal scrollbar.

Changes:

  • Add CSS rule to allow scrolling
  • Add ipywidgets example to the examples/pydata page

@gabalafou
Copy link
Collaborator Author

gabalafou commented Apr 9, 2024

Related:

1041 and this PR address two related but different scenarios. They both deal with notebook cell outputs. But this PR deals specifically when the cell output uses ipywidgets.

1041 put an overflow-x: auto rule on notebook cell outputs rendered to HTML by myst-nb because otherwise, the default value of the output div would have overflow: visible, and wide tables inside the output div would cause the entire page to expand so the user would have to scroll the entire page horizontally. (Note: nbsphinx adds overflow: auto by default.)

This PR, on the other hand, has to override an overflow: hidden rule put on a container div via ipywidgets (via Lumino), regardless of whether the widget is rendered to HTML by myst-nb or nbsphinx.

Copy link
Collaborator Author

@gabalafou gabalafou left a comment

Choose a reason for hiding this comment

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

self-review

// ipywidgets
.jp-OutputArea-output.lm-Widget {
// override overflow:hidden rule from Lumino (.lm-Widget) to allow scrolling
overflow: auto;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not entirely sure if I should set auto for both x and y or just x, but I decided to follow JupyterLab's lead, though to be honest I'm not entirely sure if the scenario described in jupyterlab/jupyterlab#6104 is applicable or not to sites built with PyData Sphinx Theme.

// ipywidgets
.jp-OutputArea-output.lm-Widget {
// override overflow:hidden rule from Lumino (.lm-Widget) to allow scrolling
overflow: auto;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: I tested that this works for both nbsphinx and myst-nb (works = allows horizontal scrolling for wide table inside an ipywidget).

I'm wondering if there's some way to test this automatically, or if we could build two example pages from the same identical notebook, one through myst-nb and the other through nbsphinx.

docs/examples/pydata.ipynb Show resolved Hide resolved
@Carreau
Copy link
Collaborator

Carreau commented May 23, 2024

Ok, let's get this one in to get feedback

@Carreau Carreau merged commit 6719f1c into pydata:main May 23, 2024
19 checks passed
@gabalafou gabalafou deleted the fix-x-scroll-ipywidget branch May 24, 2024 14:36
gabalafou added a commit to gabalafou/pydata-sphinx-theme that referenced this pull request May 24, 2024
This addresses one of the issues in pydata#1740: missing horizontal scrollbar.

- Add CSS rule to allow scrolling
- Add ipywidgets example to the examples/pydata page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: CSS CSS and SCSS related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants