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

refactor(tooltip): avoid calc inside transform for IE support #3739

Conversation

emyarod
Copy link
Member

@emyarod emyarod commented Aug 15, 2019

Closes #3671

Related: #2781, #3115, #3151

This PR refactors tooltip positioning logic to avoid calc() usage inside of CSS transform (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/104773/). We now use a combination of TRBL positioning and CSS transforms rather than relying solely on CSS transforms.

We use explicit rem values for TRBL positioning (dictated by the spec), and we use percentage values to further translate the position of the tooltip caret and body depending on the desired position and alignment

Changelog

New

  • media query for IE tooltip width and inline block display

Changed

  • tooltip body positioning logic (pure transform to TRBL + transform)
  • tooltip caret positioning logic (pure transform to TRBL + transform)

Removed

  • now unused Sass variables
  • unsupported initial and max-content values in IE

Testing / Reviewing

Ensure tooltips appear correct on all platforms and all existing use cases (including password input, icon-only button)


Regarding the point made by @tw15egan in the issue, we have a few options WRT width: max-content usage:

we can either apply a workaround for all browsers or add IE specific rules (I guess this is progressive enhancement vs graceful degradation?)

@netlify
Copy link

netlify bot commented Aug 15, 2019

Deploy preview for the-carbon-components ready!

Built with commit cf3a9fd

https://deploy-preview-3739--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Aug 15, 2019

Deploy preview for carbon-elements ready!

Built with commit cf3a9fd

https://deploy-preview-3739--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Aug 15, 2019

Deploy preview for carbon-components-react ready!

Built with commit cf3a9fd

https://deploy-preview-3739--carbon-components-react.netlify.com

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

Looks that you figured out! 🎉 Thank alot @emyarod for doing this!

@emyarod
Copy link
Member Author

emyarod commented Aug 15, 2019

@asudoh any thoughts on the width: max-content usage problem?

@asudoh
Copy link
Contributor

asudoh commented Aug 15, 2019

@emyarod Thank you for double-checking, either way is fine. I'd choose "all browsers" solution if it's straightforward, and choose IE-override solution otherwise.

@asudoh
Copy link
Contributor

asudoh commented Aug 17, 2019

@emyarod Should we go ahead with this PR or do you still have some open questions...? Thanks!

@emyarod
Copy link
Member Author

emyarod commented Aug 19, 2019

@asudoh I will add IE overrides so that we can continue to use max-content for browsers that support it

@emyarod emyarod force-pushed the 3671-tooltip-avoid-calc-inside-transform branch from a2725c8 to d618545 Compare August 20, 2019 02:15
@emyarod
Copy link
Member Author

emyarod commented Aug 20, 2019

tooltip width is now hard coded for IE, so users will have to modify that to fit their tooltip content on IE

@asudoh
Copy link
Contributor

asudoh commented Aug 20, 2019

@emyarod Thank you for the update - The latest code LGTM 👍, do you think this PR is ready to go?

@emyarod
Copy link
Member Author

emyarod commented Aug 20, 2019

@asudoh yes if IE looks good for the reviewers as well

@tw15egan
Copy link
Collaborator

@carbon-design-system/design does this look good?

@shixiedesign
Copy link
Contributor

shixiedesign commented Aug 20, 2019

@emyarod Is this refactor supposed to not change the design/behavior? There are some changes to the tooltips from a quick look – is this PR supposed to change how alignments are done? If not calculated, how are the triangles going to line up to "start, center, end"? Eg. below screenshot is supposed to be end alignment, but is not correct:

image

@emyarod
Copy link
Member Author

emyarod commented Aug 21, 2019

@shixiedesign this is a refactor, so the behavior is identical to what we settled on previously. IIRC we decided the caret would always be centered and the alignment would only affect the tooltip body

I'm still tracing the history of the discussion and will add related tickets below but the behavior you're describing is the current (approved) behavior in master branch if I'm not mistaken

the result of our discussion #2748 (comment)

@emyarod emyarod force-pushed the 3671-tooltip-avoid-calc-inside-transform branch 2 times, most recently from 912c9da to 5f99102 Compare August 21, 2019 18:53
@emyarod
Copy link
Member Author

emyarod commented Aug 21, 2019

@vincentsnagg got it, I was testing on Chromium Edge but I just added a feature query for Edge 12-15 and 16

@asudoh
Copy link
Contributor

asudoh commented Aug 23, 2019

@shixiedesign Thank you for doing the design review! Does the latest comment from @emyarod make sense? Probably if something has to be changed from UX perspective we can enter a new issue to track it...?

@emyarod emyarod force-pushed the 3671-tooltip-avoid-calc-inside-transform branch from bb57856 to ee8aa15 Compare August 23, 2019 14:35
Copy link
Contributor

@shixiedesign shixiedesign left a comment

Choose a reason for hiding this comment

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

I see. My mistake confusing definition tooltip & icon tooltip. This looks consistent with current behavior. Thanks!

@asudoh asudoh merged commit 86594dc into carbon-design-system:master Aug 24, 2019
@emyarod emyarod removed the request for review from elizabethsjudd August 26, 2019 11:26
@emyarod emyarod deleted the 3671-tooltip-avoid-calc-inside-transform branch August 26, 2019 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ToolTip Icon: Tooltip in IE is separated from pointer
6 participants