Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@raethlein
Copy link
Collaborator

@raethlein raethlein commented Dec 9, 2024

Describe your changes

This PR prevents tooltips to overflow on the left or right side.

Before:

Screenshot 2024-12-17 at 14 22 19
Screenshot 2024-12-17 at 14 22 25

After:

Screenshot 2024-12-17 at 14 21 30
Screenshot 2024-12-17 at 14 21 23

GitHub Issue Link (if applicable)

Closes #9288
Closes #9452

Testing Plan

  • E2E Tests
    • Added e2e test taking a screenshot of tooltips that previously were cut off.

Contribution License Agreement

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

@raethlein raethlein force-pushed the fix/button-help-in-sidebar branch 2 times, most recently from a171fdf to 1a61a5f Compare December 9, 2024 16:36
@raethlein raethlein added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Dec 17, 2024
@raethlein raethlein force-pushed the fix/button-help-in-sidebar branch from 1a61a5f to 89173d6 Compare December 17, 2024 12:07
@raethlein raethlein marked this pull request as ready for review December 17, 2024 13:14
@raethlein raethlein changed the title Place button tooltips automatically in sidebar Prevent tooltips from overflowing on the left or right side Dec 17, 2024
@raethlein raethlein force-pushed the fix/button-help-in-sidebar branch 2 times, most recently from 38d856b to dda83f3 Compare December 17, 2024 13:54
@raethlein raethlein force-pushed the fix/button-help-in-sidebar branch from dda83f3 to e128a64 Compare December 17, 2024 13:55
@raethlein raethlein force-pushed the fix/button-help-in-sidebar branch from e128a64 to 080cc2a Compare December 17, 2024 13:56
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of checking this via fullscreen screenshots, wouldn't it be possible to check that the bounding box of the tooltip elements is within the bounds of the screensize?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great point, I have updated the tests and removed the snapshots again 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason why this isn't dealt with the library used by baseweb? I assume it might be related to the parent element boundaries. Wouldn't the usage of the ignoreBoundary argument solve this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It looks like it might solve the issue on the right-side overflow, but not on the left-side overflow. Hence, I thought that just calculating it for both might be more consistent instead of setting a flag that somehow fixes the one but not the other, which still needs calculation.
But let me know if you think about this differently. Happy to remove the right-side overflow calculation again and setting the flag.

@raethlein raethlein force-pushed the fix/button-help-in-sidebar branch from 839e172 to 08518ce Compare December 17, 2024 15:51

const overflowRight =
xCoordinate + boundingClientRect.width - window.innerWidth
const parentsParentElement = parentElement.parentElement
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment here why we need to get the parentsParent here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment!

Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@raethlein raethlein merged commit 7889b22 into develop Dec 17, 2024
32 checks passed
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
…t#9983)

## Describe your changes

This PR prevents tooltips to overflow on the left or right side.

## GitHub Issue Link (if applicable)

Closes streamlit#9288
Closes streamlit#9452

## Testing Plan

- E2E Tests
- Added e2e test taking a screenshot of tooltips that previously were
cut off.

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
@lukasmasuch lukasmasuch deleted the fix/button-help-in-sidebar branch March 13, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Help tooltip variable aligns off screen when widget is to the right of the screen. button help hover in sidebar is not fully visible

3 participants