Skip to content

fix(tooltip): remove width override [#5612] [SWC-994] #5653

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

castastrophe
Copy link
Contributor

@castastrophe castastrophe commented Jul 31, 2025

Description

Consolidated all available CSS assets into a single tooltip.css file and removed duplicate styles from the shipped asset. Restructured similar styles together and removed unused styles to improve maintainability and reduce bundle size.

Note: Added a TODO comment on line 135 for the #tip[style] selector rule that needs additional documentation to explain its purpose and usage.

Motivation and context

The tooltip component had multiple CSS files that contained duplicate styles and unused code. This consolidation:

  • Reduces bundle size by eliminating duplicate CSS rules
  • Improves maintainability by having all styles in one location
  • Removes unused styles that were not being applied
  • Groups related styles together for better organization

Related issue(s)

Screenshots (if appropriate)

N/A - CSS consolidation only

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Basic tooltip functionality with all variants

    1. Go to Storybook Tooltip stories
    2. Test each variant (default, info, positive, negative) with different placements
    3. Verify tooltips display correctly with proper styling and positioning
    4. Expect consistent appearance across all variants and placements
  • Tooltip placement and positioning

    1. Go to Storybook Overlaid tooltip stories
    2. Test all placement options (top, bottom, left, right, top-start, top-end, etc.)
    3. Verify tooltip tips (arrows) point in correct directions
    4. Expect proper positioning relative to trigger elements
  • Tooltip animations and transitions

    1. Go to Storybook Self-managed tooltip story
    2. Hover over trigger elements to show tooltips
    3. Verify smooth fade-in/fade-out animations
    4. Expect consistent animation timing and easing
  • Tooltip in RTL (right-to-left) layout

    1. Go to Storybook Tooltip stories
    2. Set page direction to RTL (dir="rtl")
    3. Test tooltip placements, especially corner placements (top-start, top-end, etc.)
    4. Verify tooltip tips and positioning adapt correctly to RTL layout
  • High contrast mode support

    1. Go to Storybook Tooltip stories
    2. Enable high contrast mode in browser/system settings
    3. Test all tooltip variants and placements
    4. Verify proper borders and contrast in high contrast mode

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Copy link

changeset-bot bot commented Jul 31, 2025

⚠️ No Changeset found

Latest commit: 5d4e947

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

github-actions bot commented Jul 31, 2025

📚 Branch Preview

🔍 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-5653

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

Tachometer results

Currently, no packages are changed by this PR...

@castastrophe castastrophe force-pushed the castastrophe/fix-tooltip-width-gh-5612 branch 2 times, most recently from 0612da8 to 480795f Compare July 31, 2025 16:57
@castastrophe castastrophe changed the title fix(tooltip): remove width override [#5612] fix(tooltip): remove width override [#5612] [SWC-994] Jul 31, 2025
@castastrophe castastrophe force-pushed the castastrophe/fix-tooltip-width-gh-5612 branch 3 times, most recently from 72e0697 to 8e6698e Compare July 31, 2025 17:39
Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

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

This is a great start of how/why we should do this since consolidating styles fixes not only the max-width bug, but also brings back some of the placement options that didn't work before (top-start, top-end, bottom-start, bottom-end).

I also noticed looking over this that I'm not sure that the right-start, right-end, left-start, and left-end placements are doing anything. I didn't see styles for them. There are also some placement options available in CSS that we don't use here, like right top, right bottom, end top, end bottom, etc. Something we could add later on if we wanted to!

Comment on lines +172 to +175
:host([placement="bottom-start"]) #tip,
:host([placement="top-start"]) #tip {
inset-inline: var(--mod-tooltip-pointer-corner-spacing, var(--spectrum-tooltip-pointer-corner-spacing)) auto;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like top-start, top-end, bottom-start, and bottom-end all aren't working as expected on the main branch, here they're fixed so that they actually work now 🎉

Comment on lines +232 to +241
:host([placement*="right"]) #tip {
clip-path: polygon(calc(100% - var(--mod-tooltip-tip-height-percentage, var(--spectrum-tooltip-tip-height-percentage))) 50%, calc(100% + var(--mod-tooltip-tip-antialiasing-inset, var(--spectrum-tooltip-tip-antialiasing-inset))) 100%, calc(100% + var(--mod-tooltip-tip-antialiasing-inset, var(--spectrum-tooltip-tip-antialiasing-inset))) 0);
inset-inline: calc(var(--mod-tooltip-tip-block-size, var(--spectrum-tooltip-tip-block-size)) * -2) 100%;
}

:host([placement*="left"]) #tooltip #tip {
:host([placement*="right"][dir="rtl"]) #tip {
clip-path: polygon(var(--mod-tooltip-tip-height-percentage, var(--spectrum-tooltip-tip-height-percentage)) 50%, calc(100% + var(--mod-tooltip-tip-antialiasing-inset, var(--spectrum-tooltip-tip-antialiasing-inset))) 100%, calc(100% + var(--mod-tooltip-tip-antialiasing-inset, var(--spectrum-tooltip-tip-antialiasing-inset))) 0);
left: auto;
right: 100%;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the clip-paths here and also for the corresponding [placement*="left"] may be the same, it might be possible to eliminate the rtl clip-path. I'm less sure about inset-inline vs. left/right but if we were to do this for real this seems like a good opportunity to start using logical properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we used left and right here with the intention that we didn't want it to respond to changes in language direction. Our docs are meant to guide users to start and end as the preferred but for use-cases where they want positioning fixed regardless of language, these are available.

@castastrophe castastrophe force-pushed the castastrophe/fix-tooltip-width-gh-5612 branch 2 times, most recently from 0b4f915 to 3e1e2ab Compare August 1, 2025 19:49
@castastrophe castastrophe force-pushed the castastrophe/fix-tooltip-width-gh-5612 branch from 3e1e2ab to 5d4e947 Compare August 7, 2025 14:27
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.

[Bug]: Tooltip max-width overrides --mod variable
2 participants