Skip to content

Conversation

@willhuang1997
Copy link
Contributor

@willhuang1997 willhuang1997 commented Nov 28, 2022

📚 Context

When I was fixing the fullscreen bug where the PlotlyChart component was not properly keeping state of width and height, I defaulted the height and width to incorrect heights and widths. Because of this, I broke the useContainerWidth parameter and when setting height to the chart. In addition, in order to truly solve the full screen issue, we need to use useLayoutEffect instead of useEffect.

Explanation about both can be found here: https://kentcdodds.com/blog/useeffect-vs-uselayouteffect

Testing matrix and methodology:

Goal: making sure the coverage on testing is truly correct for height / width changes.

In 2 of the e2e tests, we have the height and width manually changed with each theme.
Testing for fullscreen which is done manually and through some unit tests.
Testing for useContainerWidth for false, true are also in unit tests.
Lmk if I am missing any other tests.

Please describe the project or issue background here

  • What kind of change does this PR introduce?

    • Bugfix
    • Feature
    • Refactoring
    • Other, please describe:

🧠 Description of Changes

  • Add bullet points summarizing your changes here

    • This is a breaking API change
    • This is a visible (user-facing) change

Revised:
Screen Shot 2022-11-28 at 12 29 26 PM

Insert screenshot of your updated UI/code here

Current:

Insert screenshot of existing UI/code here
Screen Shot 2022-11-28 at 12 30 13 PM

🧪 Testing Done

  • Screenshots included
  • Added/Updated unit tests
  • Added/Updated e2e tests

🌐 References

Does this depend on other work, documents, or tickets?


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@willhuang1997 willhuang1997 marked this pull request as ready for review November 29, 2022 00:37
@AnOctopus AnOctopus self-requested a review November 29, 2022 00:55

// Update config and spec references iff the theme or props change
useEffect(() => {
useLayoutEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

since useLayoutEffect is unusual, consider adding a comment about why we use it instead of useEffect, or include a link to an explanation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

@AnOctopus AnOctopus added the security-assessment-completed Security assessment has been completed for PR label Nov 29, 2022
@AnOctopus AnOctopus merged commit 39d4346 into streamlit:develop Nov 29, 2022
tconkling added a commit that referenced this pull request Nov 30, 2022
* develop:
  Pin pyflakes in autoflake hook (#5790)
  Fix plotly height attributes and useContainerWidth (#5779)
tconkling added a commit to tconkling/streamlit that referenced this pull request Nov 30, 2022
* feature/ReleaseCacheV2:
  Rename: cache_data, cache_resource (streamlit#5785)
  Pin pyflakes in autoflake hook (streamlit#5790)
  Fix plotly height attributes and useContainerWidth (streamlit#5779)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plotly charts ignore HEIGHT attribute after bug fix #5645

2 participants